Find Method and Forms

  • Thread starter Thread starter Saar
  • Start date Start date
S

Saar

I am using VBA to locate a specific record identified
through a list box. The record key is ENumber (a
string). The find method works great. I can find the
record (as shown in the immediate window) but for a while
couldn't get a form to display anything other than the
first record in the table. I can now get it to display my
found record, but only as a "read only table". I need to
make changes, not just a read only. Below is the
pertinent coding. How do I display a recordset record
located with the Find Method in a second form that is
updateable?

Dim rst as new adodb.recordset
dim cnn as new adodb.connection
set cnn = currentproject.connection
rst.Open "TblE", cnn, adopenstatic, adlockoptimistic
rst.Find "ENumber = '" & HoldEQ & "'"
' HoldEq is the string variable that contains the
ENumber from the list box

' this routine locates the record just fine but won't
display on the form.
If I add the line:

set Me.Recordset = rst
' just after the rst.open then the new form will open
with the correct record displayed but as a read only.

There must be a way to display the record after the Find
Method.

Thanks
 
Try setting the RecordSource of the form rather than trying to find the
record in a separate recordset.

Me.RecordSource = "Select * From TblE Where ENumber = """ & HoldEQ & """"

This should show just the record selected from the listbox.

Rod Scoullar.
 
Back
Top