syntax - string vs integer

S

slowuptake

The borrowed code below returns type mismatch error when attempting to
evaluate .FindFirst

I assume it is because IngMyVar is an integer, and the code was written for
a string. However my knowledge of syntax is weak, and I haven't stumbled
across the proper syntax after considerable trial and error.

Suspect it is a simple problem for the more skilled.
Can anyone help?

regards,
Slowuptake


Code ==>

Dim IngMyVar As Long

With Me.RecordsetClone
.FindFirst "[idnTimeCardID] = '" & IngMyVar & "'"
If .NoMatch Then
MsgBox "Timeheet not found!", vbExclamation
Else
Me.Bookmark = .Bookmark
End If
End With
 
C

Chris

Remove the single quotation marks in the FindFirst string, and it should work.

HTH

Chris
 
O

Ofer

To use the filter on a string type the syntax should be as you wrote
FindFirst "[idnTimeCardID] = '" & IngMyVar & "'"

If idnTimeCardID type is Number
FindFirst "[idnTimeCardID] = " & IngMyVar

If idnTimeCardID type was date then
FindFirst "[idnTimeCardID] = #" & IngMyVar & "#"

Good luck
 
S

slowuptake

this works grand - thanks,
slowuptake

Ofer said:
To use the filter on a string type the syntax should be as you wrote
FindFirst "[idnTimeCardID] = '" & IngMyVar & "'"

If idnTimeCardID type is Number
FindFirst "[idnTimeCardID] = " & IngMyVar

If idnTimeCardID type was date then
FindFirst "[idnTimeCardID] = #" & IngMyVar & "#"

Good luck

slowuptake said:
The borrowed code below returns type mismatch error when attempting to
evaluate .FindFirst

I assume it is because IngMyVar is an integer, and the code was written for
a string. However my knowledge of syntax is weak, and I haven't stumbled
across the proper syntax after considerable trial and error.

Suspect it is a simple problem for the more skilled.
Can anyone help?

regards,
Slowuptake


Code ==>

Dim IngMyVar As Long

With Me.RecordsetClone
.FindFirst "[idnTimeCardID] = '" & IngMyVar & "'"
If .NoMatch Then
MsgBox "Timeheet not found!", vbExclamation
Else
Me.Bookmark = .Bookmark
End If
End With
 
S

slowuptake

this works grand - thanks,
slowuptake

Chris said:
Remove the single quotation marks in the FindFirst string, and it should work.

HTH

Chris


slowuptake said:
The borrowed code below returns type mismatch error when attempting to
evaluate .FindFirst

I assume it is because IngMyVar is an integer, and the code was written for
a string. However my knowledge of syntax is weak, and I haven't stumbled
across the proper syntax after considerable trial and error.

Suspect it is a simple problem for the more skilled.
Can anyone help?

regards,
Slowuptake


Code ==>

Dim IngMyVar As Long

With Me.RecordsetClone
.FindFirst "[idnTimeCardID] = '" & IngMyVar & "'"
If .NoMatch Then
MsgBox "Timeheet not found!", vbExclamation
Else
Me.Bookmark = .Bookmark
End If
End With
 
Top