FindFirst Method syntax

G

Guest

Please help me to understand the syntax for the Recordset.Findfirst when
searching for a CustomerID field using a combo box. First I declare an
Object variable with Dim, then assign a recordsetclone to the variable. Then
I use the FindFirst method to synchronize the combo box with the first
instance of the record on the form with identical ID numbers. But the
quotation marks and especially the ampersand are what confuse me. I am using
Access 2000.
Can you help please.
 
K

Ken Snell \(MVP\)

It'll be easier to provide explanations if you post the code that you have
right now. We then can provide suggestions for how to correct it if needed.
 
M

Marshall Barton

boomer said:
Please help me to understand the syntax for the Recordset.Findfirst when
searching for a CustomerID field using a combo box. First I declare an
Object variable with Dim, then assign a recordsetclone to the variable. Then
I use the FindFirst method to synchronize the combo box with the first
instance of the record on the form with identical ID numbers. But the
quotation marks and especially the ampersand are what confuse me. I am using
Access 2000.


The tried and true code sequence since A95 is:

If Me.Dirty Then Me.Dirty = False 'save any changes
With Me.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "[name of number field] = " & Me.combo
'or .FindFirst "[name of text field] = """ & Me.combo & """"
If Not .NoMatch Then Me.Bookmark = .Bookmark
End If
End With

Logically, this should work just as well in A2002 and A2003
(not sure about A2000)

If Me.Dirty Then Me.Dirty = False 'save any changes
With Me.Recordset
If .RecordCount > 0 Then
.FindFirst "[name of number field] = " & Me.combo
'or .FindFirst "[name of text field] = """ & Me.combo & """"
End If
End With
 
D

davjoh123

Could it be that FindFirst is a method of DAO and you do not have a
reference set to DAO?


Marshall said:
boomer said:
Please help me to understand the syntax for the Recordset.Findfirst when
searching for a CustomerID field using a combo box. First I declare an
Object variable with Dim, then assign a recordsetclone to the variable. Then
I use the FindFirst method to synchronize the combo box with the first
instance of the record on the form with identical ID numbers. But the
quotation marks and especially the ampersand are what confuse me. I am using
Access 2000.


The tried and true code sequence since A95 is:

If Me.Dirty Then Me.Dirty = False 'save any changes
With Me.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "[name of number field] = " & Me.combo
'or .FindFirst "[name of text field] = """ & Me.combo & """"
If Not .NoMatch Then Me.Bookmark = .Bookmark
End If
End With

Logically, this should work just as well in A2002 and A2003
(not sure about A2000)

If Me.Dirty Then Me.Dirty = False 'save any changes
With Me.Recordset
If .RecordCount > 0 Then
.FindFirst "[name of number field] = " & Me.combo
'or .FindFirst "[name of text field] = """ & Me.combo & """"
End If
End With
 

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