If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Inserting a value into a report triggered by a select query
I have created a form which generates an invoice number. I have also created
an invoice (report) which is based on the values in this form. The report is based on a query which prompts for invoice number. Thus when the user prints the invoice based on the data in the current screen, they are prompted to enter the invoice number (a duplication of effort). What I would like to do is code the form to pass the current invoice number to the query which powers the report (invoice). I have tried to code this in the On Click command button Private Sub Preview_Invoice_Click() On Error GoTo Err_Preview_Invoice_Click If Not IsNull(Me![InvoiceID]) Then Invoice![InvoiceID] = Me![InvoiceID] DoCmd.OpenReport "Invoice", acPreview Exit_Preview_Invoice_Click: Exit Sub Err_Preview_Invoice_Click: MsgBox Err.Description Resume Exit_Preview_Invoice_Click End Sub However, I can not get the invoice date to pass into the invoice report. Am I off with the command passing the invoice number to the invoice report (should that code come after the DoCmd code?) Is it because I am passing the invoice number to the report, rather than the query? Please advise. -- Robert Robinson |
#2
|
|||
|
|||
Inserting a value into a report triggered by a select query
Robert:
You can directly reference the InvoiceID control in your form in the query behind the report. This is generally referred to as the "Query By Form" technique. The following KB article gives more information. http://support.microsoft.com/default...b;en-us;304428 -- David Lloyd MCSD .NET http://LemingtonConsulting.com This response is supplied "as is" without any representations or warranties. "Robert Robinson" wrote in message ... I have created a form which generates an invoice number. I have also created an invoice (report) which is based on the values in this form. The report is based on a query which prompts for invoice number. Thus when the user prints the invoice based on the data in the current screen, they are prompted to enter the invoice number (a duplication of effort). What I would like to do is code the form to pass the current invoice number to the query which powers the report (invoice). I have tried to code this in the On Click command button Private Sub Preview_Invoice_Click() On Error GoTo Err_Preview_Invoice_Click If Not IsNull(Me![InvoiceID]) Then Invoice![InvoiceID] = Me![InvoiceID] DoCmd.OpenReport "Invoice", acPreview Exit_Preview_Invoice_Click: Exit Sub Err_Preview_Invoice_Click: MsgBox Err.Description Resume Exit_Preview_Invoice_Click End Sub However, I can not get the invoice date to pass into the invoice report. Am I off with the command passing the invoice number to the invoice report (should that code come after the DoCmd code?) Is it because I am passing the invoice number to the report, rather than the query? Please advise. -- Robert Robinson |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error when running Query, but not Report | Blaze | Running & Setting Up Queries | 29 | September 9th, 2005 05:40 AM |
To Sharkbyte and all: Calculate a total values in group level | Ally | General Discussion | 6 | June 13th, 2005 08:16 PM |
Big number gives error! | Sara Mellen | Running & Setting Up Queries | 8 | October 11th, 2004 02:48 AM |
Taher | Setting Up & Running Reports | 1 | August 31st, 2004 09:07 PM | |
Display Parameter from Form on Report | sara | Setting Up & Running Reports | 10 | July 19th, 2004 04:54 PM |