DLookup syntax

R

RipperT

I have a button that prints a report that also contains code to print to a
specific printer. The code is supposed to lookup the printer in a table and
plug it into strPrinterOne, but it's not working.

This line works:
strPrinterOne = "\\NA_COBB_TREE\IBD_DD_NDPS10.IBD.GR.G.COBB.NA"

This line doesn't:
strPrinterOne = DLookup("[PrinterName]", "tblPrinters", _
"[Printer] = '" & PrimaryPrinter & "'")

Aren't these two the same if the printer path in the String literal is in
the PrinterName column of tblPrinters where the Printer field is Primary
Printer? Nothing happens when I click this button. Help!

Rip
 
R

Rick Brandt

RipperT said:
I have a button that prints a report that also contains code to print
to a specific printer. The code is supposed to lookup the printer in
a table and plug it into strPrinterOne, but it's not working.

This line works:
strPrinterOne = "\\NA_COBB_TREE\IBD_DD_NDPS10.IBD.GR.G.COBB.NA"

This line doesn't:
strPrinterOne = DLookup("[PrinterName]", "tblPrinters", _
"[Printer] = '" & PrimaryPrinter & "'")

Aren't these two the same if the printer path in the String literal
is in the PrinterName column of tblPrinters where the Printer field
is Primary Printer? Nothing happens when I click this button. Help!

Rip

Open the immediate window <Ctl-G> then type...

?DLookup("[PrinterName]", "tblPrinters", _
"[Printer] = '" & PrimaryPrinter & "'") <enter>

What is returned when you press <enter>?
 
Top