FindFirst when field is Long Integer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I use the .FindFirst method when the field I need to search is a Long
Integer?

..FindFirst Me.ID

ID is Long Integer

Thank you in advance.
 
The only difference for data type is the syntax.
Text field criteria must be enclosed in single or double quotes.
Date field criteria must be enclosed in #
Numeric field criteria uses no delimiters.

In any case, your syntax included what you want to find but does not include
where you want to find it. The correct syntax is:

..FindFirst "[FieldNameToSearch] = " & Me.ID

If ID were text
..FindFirst "[FieldNameToSearch] = '" & Me.ID & "'"

If ID were a date
..FindFirst "[FieldNameToSearch] = #" & Me.ID & "#"
 
You don't. the .findfirst method is used with recordsets, not fields. What
are you trying to do?
 
Well, I guess i was wrong- I've never used it like that before...

Corey-g said:
You don't. the .findfirst method is used with recordsets, not fields. What
are you trying to do?
How do I use the .FindFirst method when the field I need to search is a Long
Integer?
[quoted text clipped - 4 lines]
Thank you in advance.
 
Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
Used this method to search for a date and filter the records. It worked
well. Thanks for that. However when the date starts with a zero eg.
01/10/2006 for some reason it can't find the date. It will find any other
date with no problem.
Many thanks for any help.

Klatuu said:
The only difference for data type is the syntax.
Text field criteria must be enclosed in single or double quotes.
Date field criteria must be enclosed in #
Numeric field criteria uses no delimiters.

In any case, your syntax included what you want to find but does not include
where you want to find it. The correct syntax is:

.FindFirst "[FieldNameToSearch] = " & Me.ID

If ID were text
.FindFirst "[FieldNameToSearch] = '" & Me.ID & "'"

If ID were a date
.FindFirst "[FieldNameToSearch] = #" & Me.ID & "#"



Ed Bloom said:
How do I use the .FindFirst method when the field I need to search is a Long
Integer?

.FindFirst Me.ID

ID is Long Integer

Thank you in advance.
 
Back
Top