Find record in a dropdown box

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

Guest

Is there a way to search for a record from a global variable, and search it
in dropdown box and select the record found all through code?
Thanks
 
Hi,


You can use DLookup to find a field given a criteria, criteria which can be
dependant of a variable:

DLookup( "address", "Companies", "CompanyNumber=" &
MyGlobalVariable )



To pick the whole record, try to use the recordset clone.


With Me.RecordsetClone
.FindFirst "CompanyNumber= " & myGlobalVar ' note the
starting dot
If Not .NoMatch then
Me.OtherControl = .Fields("CompanyName")
Me.SomeOtherControl = .Fields("ContactName")
End If
End With




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top