emulate combo lookup?

Matthew Snook

NW Salmon Database
Local time
Today, 23:43
Joined
Apr 19, 2001
Messages
133
I now have data coming through a serial port from a peripheral device, and I've learned how to shunt it into the appropriate field for data storage. Now I'd like to use the data to locate a related record, in the same manner that a combo box can be used to select related data, return the record ID, and instantly (or quickly) go to that record.

What I'd like to do is return that ID using a lookup of some kind, since the combo box won't allow me to assign the data from the serial device. I've tried the lookup function, but it seems very slow compared to a combo box. How do I build a lookup that is just as fast as a combo box?

Matt
 
This will do a lookup for you and return your data in a recordset...

dim MyDB as database
dim MyRecs as recordset
dim MySQL as string
dim YourID

MySQL = "SELECT [FieldName] FROM [TableName] Where [FieldCriteria]='" & txtCriteria & "'"

set MyDB = currentdb
set MyRecs = MyDB.openrecordset(MySQL)

YourID = MyRecs!ID_FieldName

MyDB.close
set MyRecs = nothing
set MyDB = nothing


'Note that I used the tic marks(') in the SQL statement. This is if your criteria is a string. If your criteria is a number, then just omit the tick marks('). Hope this helps.

Doug
 
Thanks, I'll give it a try. I was wondering if there was a way other than query simply because I thought maybe the query would be too slow, and the combo box idea is so quick!

Thanks again, and here goes...

Matt
 

Users who are viewing this thread

Back
Top Bottom