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

syntax error

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I have an syntax error, missing operatior in the following code:
Dim StrSQL As String
StrSQL = " DLookUp('[items2]','[products]','[ProductID]=' & [ProductID])"
Me!Stueck.ControlSource = StrSQL

Can yo help me find the error ?
 
DlookUp is a function, you can use it in an SQL string, but not in the way you show. You can just use it by itself:

strAns= DLookUp("[items2]","[products]","[ProductID]=" & [ProductID])

You may wish to check for nulls.
 
You would have to include the "="
Code:
Dim StrSQL As String
StrSQL = "[red][b]=[/b][/red]DLookUp('[items2]','[products]','[ProductID]=' & [ProductID])"
Me!Stueck.ControlSource = StrSQL
I don't know why you are using code rather than just setting the control source to:
=DLookUp("[items2]","[products]","[ProductID]=" & [ProductID])
This assumes ProductID is numeric.

Also, why would you not have the Products table in the report's record source query joined to the ProductID in one of your current tables. Then just add the Items2 field to the Record Source fields?



Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top