FindFirst when field is Long Integer

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.
 
G

Guest

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 & "#"
 
C

Corey-g via AccessMonster.com

You don't. the .findfirst method is used with recordsets, not fields. What
are you trying to do?
 
C

Corey-g via AccessMonster.com

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.
 
Z

Zedbiker

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top