Re: DLookup syntax

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



It returns Null, but I figured it out. It is now:

strPrinterOne = DLookup("[PrinterName]", "tblPrinters", _
"[Printer] = 'Primary'")

In the last argument, I removed the ampersands and the inner double quotes,
leaving 'Primary'. It works, but I don't know why.

Thanks for the assist.

Ripper

"Rick Brandt" <rickbrandt2@xxxxxxxxxxx> wrote in message
news:LwuAh.22036$zH1.7942@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RipperT wrote:
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>?


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




.



Relevant Pages

  • RE: Use of Variable in Sum
    ... "Jacob Skaria" wrote: ... Quotes represents string values.. ... Ampersands are used to combine variables OR strings... ...
    (microsoft.public.excel.programming)
  • RE: Use of Variable in Sum
    ... Thanks Sue. ... I have tried to explain a bit about strings and ampersands. ... Quotes represents string values.. ...
    (microsoft.public.excel.programming)
  • Re: Prefill Coding Error
    ... Note that Marshall suggested using quotes and ampersands. ... I save the form the name Tom Jones is not displaying in the form field when ...
    (microsoft.public.access.modulesdaovba)
  • Re: indirect function?
    ... I was and still am unsure of the reasons for the quotes and ... ampersands and why they go where they do, but I plugged in my columns ...
    (microsoft.public.excel.worksheet.functions)