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

DLookup Syntax in Query

Status
Not open for further replies.

georgesOne

Technical User
Joined
Jul 2, 2004
Messages
176
Location
JP
Hi,
after more than six hours I see no tree because of too much forest...

I have this query

SELECT DISTINCT DLookUp("ProductLine","htbl_ProductLine","ProductLineID = " & tbl_Formulation.ProductLine) AS ProductLine
FROM tbl_Formulation
WHERE NOT ISNULL(tbl_Formulation.ProductLine);

which works well and need now to make a more general expression as below:

strSQL = "SELECT DISTINCT DLookUp(""" & sField & """,""" & sTable & """,""" & sID & """ & tbl_Formulation.ProductLine) AS " & sField FROM " & cboTable & " WHERE NOT ISNULL(" & cboTable & "." & sField & ")"

where

sField = Controls("cboFieldName" & i)
sTable = "htbl_" & Controls("cboFieldName" & i)
sID = Controls("cboFieldName" & i) & "ID = "

values from combo controls are. This is for a generic search form.

This works also well, but I need to replace the specific term 'tbl_Formulation.ProductLine' in the LookUp function with the general terms 'cboTable' and 'sField'.

Nothing was successful. Any idea?

Thanks for any help & good night, georges.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top