UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Data type mismatch 3464    
 
   
Emess
post Dec 17 2008, 12:27 PM
Post #1

UtterAccess Enthusiast
Posts: 69



Private Sub txtStationRunNumber_BeforeUpdate(Cancel As Integer)
Dim rst As DAO.Recordset
Dim strStationRunNumber As String
Dim strCriteria As String
Dim lngBookmark As Long

I am using the following code to check if a value has already been entered. If so, I want to clear only that field. However, I get the error mismatch message and two fields get cleared out. All help is appreciated.

If Nz(Me.StationRunNumber, "") <> "" Then
strStationRunNumber = Me.StationRunNumber

Set rst = Me.RecordsetClone

strCriteria = "[StationRunNumber]='" & strStationRunNumber & "'"
lngBookmark = Nz(DLookup("StationRunNumber", "tblIncidents", strCriteria), 0)
If lngBookmark > 0 Then
Me.Undo
MsgBox "The Station Run Number of " & strStationRunNumber & " already exists in the database." & vbCrLf & vbCrLf & _
"Please re-enter the Station Run Number", vbInformation, "Duplicate Station Run Number " & strStationRunNumber
End If
rst.Close
Set rst = Nothing
End If
End Sub
Go to the top of the page
 
+
Emess
post Dec 17 2008, 12:29 PM
Post #2

UtterAccess Enthusiast
Posts: 69



I should also mention that the StationRunNumber is a numeric field.
Go to the top of the page
 
+
niesz
post Dec 17 2008, 12:53 PM
Post #3

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



If StationRunNumber is a numeric then it should not be enclosed in single quotes here:

strCriteria = "[StationRunNumber]='" & strStationRunNumber & "'"
Go to the top of the page
 
+
Emess
post Dec 17 2008, 03:32 PM
Post #4

UtterAccess Enthusiast
Posts: 69



Just so I understand, it should be like this?

strCriteria = "['StationRunNumber']='" & strStationRunNumber & "'"

Is that the only place I need to change it?

THanks.
Go to the top of the page
 
+
niesz
post Dec 17 2008, 03:36 PM
Post #5

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



No ... I said it should NOT be enclosed ...

strCriteria = "[StationRunNumber]=" & strStationRunNumber
Go to the top of the page
 
+
Emess
post Dec 17 2008, 03:41 PM
Post #6

UtterAccess Enthusiast
Posts: 69



Thank you for your help.
Go to the top of the page
 
+
niesz
post Dec 17 2008, 03:47 PM
Post #7

Utter A-fishin'-ado
Posts: 17,723
From: Cincinnati, Ohio, USA . . . ><((((°>



NP. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 12:50 AM