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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup an Access Table

Status
Not open for further replies.

vwhite

Programmer
Oct 4, 2001
87
AU
Hi,

I am using a DAO Connection from VB to an Access database. I wanted to know if there was an easy way to lookup a single value - in the same kind of way that Dlookup works in Access

e.g.
value = DLookup("[COSTING_COMPONENT_ID]", "COSTING_COMPONENTS_LKP_TBL", "COMPONENT_TYPE='Salaried Positions'")

instead of having to write a an SQL string and open the recordset etc.

Cheers and thanks
VW...
 
You are either going to need to use an SQL statement or use an existing access query to return specific results with DAO or ADO for that matter.

Another way would be to use data bound controls such as the data control. Thanks and Good Luck!

zemp
 
Thanks zemp,

I guess I can always write my own version of Dlookup that I can reuse where required.

Cheers
VW..
 

And that is just what the DLookUp is: A funtion that creates a recordset to get the data based on the criteria passed.

One bit of help:

If the data is coming from the same source, you might want to create a second look-up function (or pass a parameter to the first look-up) to where not only the same connection gets used, but, where it uses a recordset clone from an existing recordset...It generally will work faster and save on net traffic, (if the data is with-in an existing recordset and you do not want to move the original recordset's cursor position).
This (the latter suggestion) is of course only possible if the recordset supports clones.
[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top