VoodooRage
Programmer
Hi,
I have an SQL statement that contains a DLookup as follows (pasted from the query builder):
DoCmd.RunSQL = "SELECT CPUMstr.CPUSN, CPUMstr.CPUMfg, " _
& " CPUMstr.CPUModel, CPUMstr.CPUAsset, " _
& "DLookUp("[CPUSN]","Users","[CPUSN] = " _
& "'" & [CPUSN] & "'"
AS Expr1, " _
& " CPUMstr.CPUBench FROM CPUMstr " _
& "WHERE (((DLookUp("[CPUSN]","Users","[CPUSN] = '" & [CPUSN] & "'"
) Is Null) AND ((CPUMstr.CPUBench)=True));
The problem is with the literals in the Dlookup. I can't seem to get the SQL to work in VB because of the literals required in the Dlookup. When I try to code the syntax for the text portion of the dlookup "[CPUSN]" to ''[CPUSN]'' at the end of the Dlookup where ''[CPUSN] ='' & '' ' '' & ''[CPUSN]'' & '' ' '' & ) is where the dlookup seems to get confused.
Thanks for any help, you people are super!
The query runs fine in the Query Builder but like I said the literals in the Dlookup are throwing the VB SQL into a tither.
I have an SQL statement that contains a DLookup as follows (pasted from the query builder):
DoCmd.RunSQL = "SELECT CPUMstr.CPUSN, CPUMstr.CPUMfg, " _
& " CPUMstr.CPUModel, CPUMstr.CPUAsset, " _
& "DLookUp("[CPUSN]","Users","[CPUSN] = " _
& "'" & [CPUSN] & "'"
& " CPUMstr.CPUBench FROM CPUMstr " _
& "WHERE (((DLookUp("[CPUSN]","Users","[CPUSN] = '" & [CPUSN] & "'"
The problem is with the literals in the Dlookup. I can't seem to get the SQL to work in VB because of the literals required in the Dlookup. When I try to code the syntax for the text portion of the dlookup "[CPUSN]" to ''[CPUSN]'' at the end of the Dlookup where ''[CPUSN] ='' & '' ' '' & ''[CPUSN]'' & '' ' '' & ) is where the dlookup seems to get confused.
Thanks for any help, you people are super!
The query runs fine in the Query Builder but like I said the literals in the Dlookup are throwing the VB SQL into a tither.