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

Getting a field from a table 2

Status
Not open for further replies.

Michael57

Technical User
Nov 15, 2005
131
CA
I have some code that creates pdf files for quotes based on a range set in a form. Right now i write out the pdf files using the quote number as the file name. I get the quote number from the form. I would like to be able to also add the customer name to the pdf file name. How can I generate code to go to the table and select the customer name that corresponds to the quote# I'm printing.
 
You may consider the DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry I'm not very experienced. What would this code look like. Thanks
 
Ok my code looks like this and I get runtime error 2001 You cancelled the previous operation. Note this code worked prior to putting in the dlookup.

Private Sub Command15_Click()
Dim CustomerName As Variant

PrintQuoteNo = Me.StartQuoteNo
While (PrintQuoteNo <= Me.EndQuoteNo)
CustomerName = DLookup("[Customer]", "QuoteData", "[QuoteNo]=[PrintQuoteNo]")
DoCmd.OpenReport "QuotePrintSignedPDF", acViewNormal, , "QuoteNo =" & PrintQuoteNo & Customer
DoCmd.Close acReport, "QuotePrint"
FileFound = Dir("\\Server1\common\Sales\Access\Quotes\QuotePrintSignedPDF.pdf")
Do While FileFound = ""
WaitABit
FileFound = Dir("\\Server1\common\Sales\Access\Quotes\QuotePrintSignedPDF.pdf")
Loop
Name "\\Server1\common\Sales\Access\Quotes\QuotePrintSignedPDF.pdf" As "\\Server1\common\Sales\Access\Quotes\Quote" & PrintQuoteNo & ".pdf"
PrintQuoteNo = (PrintQuoteNo + 1)
Wend
End Sub
 
Provided that the Query/table QuoteData has fields named Customer and QuoteNo:
CustomerName = DLookup("Customer", "QuoteData", "QuoteNo=" & PrintQuoteNo)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top