Opening a Report

D

DS

I have one report that I would like to open from several forms, however on
the report I have a couple of DLookup functions.

DLookUp("TaxRate","tblTaxRates", "SalesID = Forms!frmCheck!TxtSalesID)

The problem is how can I code these functions so that they are not tied to
any particuar form. Normally when I open a form frm a form I would put the
code on the form, unfortunatly Reports don't seem to wrk that way. Any help
apprecitaed.
Thanks
DS
 
O

Ofer Cohen

If this question connected to the new post, you can get the ID from the
report record source, if there is no connection, then you can try something
like
=========================
Declare a global variable in a module

Global SaleId As Long
=========================
Set a function in the module that return the varaible

Function GetSaleId ()
GetSaleId = SaleId
End Function
=========================
In the forms before you open the report set the SaleId

SaleId = Forms!frmCheck!TxtSalesID
Docmd.OpenReport "ReportName"
=========================
Change the If function to
DLookUp("TaxRate","tblTaxRates", "SalesID = " & GetSaleId ())
 
D

DS

Sounds good I never would of thought of it! Works well. Oh yeah, the next
post is unrelated.
Thanks
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top