ado find not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Am trying to get form to show a record the user does a search for,
strSearch is a text variable of (VehLicence = "cab123") VehLicence is
a text field in tblCase_Vehicle. However nothing is happening. Any
help would be appreciated.

Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rsveh As New ADODB.Recordset
rsveh.ActiveConnection = cnn1
rsveh.CursorType = adOpenDynamic
rsveh.Open "SELECT * FROM tblCase_VehicleVehicle"
rsveh.MoveFirst
rsveh.Find strSearch
 
What are you expecting to have happen?

Once you've used the Find method, you then need to check whether the
recordset is at EOF (which means there was no match), or else look at what
value is current in the recordset. See
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthfindx.asp for an
example.

However, why are you using Find? Why not put a condition on the SQL you're
using to open the recordset?

rsveh.Open "SELECT * FROM tblCase_VehicleVehicle WHERE " & strSearch
 

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

Back
Top