FindFirst Method syntax

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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
 
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
 
Back
Top