Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Button Coding Problems 1

Status
Not open for further replies.

dots

Technical User
Jul 13, 2001
24
US
I am trying to put a simple search button on a form that will allow a user to enter in a Work Order number and click the search button to go to that record.

The code is:

Dim rs As Recordset
Dim Bkm As String
Dim stWorkOrder As Integer

stWorkOrder = Me.[SrchWO]
Set rs = Me.RecordsetClone

rs.FindFirst ("[Work Order] =" & stWorkOrder)
If rs.NoMatch Then

MsgBox "No records were found for this work order number"

Else
Bkm = rs.Bookmark
rs.Close
Me.Bookmark -Bkm

End If

SrchWO is the user's input field and Work Order is the field I want to search on.

Access does not like this code. At first, it could not find the Work Order reference. I've tried different variations of parenthesis, quote marks, etc. Now, it is telling me "Method or Data Member not found" on the rs.FindFirst.

Can someone tell me what I'm doing wrong here. I've spent hours on something that probably should have taken minutes.
 
Ensure the dao library is checked (in any module Tools | References - Microsoft DAO 3.N Library)

[tt]dim rs as dao.recordset

' also try
rs.FindFirst "[Work Order] =" & stWorkOrder[/tt]

Roy-Vidar
 
are you using a DAO or an ADO recordset?

If it is dao then it should be fine but if you are using an ado then you need to change it to .Find

Check your references to make sure you aren't reference both Microsoft DAO 3.5x or 3.6 and Microsoft ActiveX Data Objects library or you will have to Dim your recordset as either an ADODB.Recordset or DAO.Recordset
 
Thank you Roy. It works perfectly now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top