command button for find records

  • Thread starter Scott_Brasted via AccessMonster.com
  • Start date
S

Scott_Brasted via AccessMonster.com

Greetings,

I have the following code for a command button on an form to find records. I
get a "compile error: method or data member not found" when I save and
compile and when I click the command button.

clientLastName is the field name and txtCLN is the name of the txt box for
clientLastName on the form. Can anyone tell what simple mistake I am making
or what I am overlooking?

Thanks,
Scott

-----------------------------
Private Sub cmdFindLastName_Click()
Dim rs As Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "[clientLastName] = '" & (Me!txtCLN) & "'"

If rs.NoMatch = False Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Entry not found"
End If

End Sub
__________________
 
J

Jeanette Cunningham

Put in a debug.print to see what access gets for txtCLN.
See below for where the debug.print statement goes.

If that won't work, the form maybe starting to get corrupt.
You can comment out that whole sub and see if the code still compiles.

You can make a new textbox for clientLastName and name it something
different from txtCLN.
Use the new one in the code and see if that will compile.


-----------------------------
Private Sub cmdFindLastName_Click()
Dim rs As Recordset

Set rs = Me.RecordsetClone
Debug.Print Me!txtCLN
rs.FindFirst "[clientLastName] = '" & (Me!txtCLN) & "'"

If rs.NoMatch = False Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Entry not found"
End If

End Sub
__________________


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
A

Allen Browne

Which line gives the error?

Try replacing:
Dim rs As Recordset
with:
Dim rs As DAO.Recordset
Explanation:
http://allenbrowne.com/ser-38.html

If that's not it, break the FindFirst line down like this:
Dim strWhere As String
strWhere = "[clientLastName] = """ & Me!txtCLN & """"
rs.FindFirst strWhere
This may help you identify whether the missing thing is the text box txtCLN
or the field named clientLastName.
 
S

Scott_Brasted via AccessMonster.com

Thanks for the reply. After posting this I came upon your (Allen's) combo box
find page and I have applied it to great success. So I do not think this idea
is necessary any more, but thanks for the help.

Best,
Scott

Allen said:
Which line gives the error?

Try replacing:
Dim rs As Recordset
with:
Dim rs As DAO.Recordset
Explanation:
http://allenbrowne.com/ser-38.html

If that's not it, break the FindFirst line down like this:
Dim strWhere As String
strWhere = "[clientLastName] = """ & Me!txtCLN & """"
rs.FindFirst strWhere
This may help you identify whether the missing thing is the text box txtCLN
or the field named clientLastName.
Greetings,
[quoted text clipped - 26 lines]
End Sub
__________________
 

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