I built myself a database to track hours.
From this I create invoices and track them. Previously I had to enter the Invoice information in the form. Also, when I created the invoice I had to enter it in pop up boxes.
I did some searches and found out about parameter queries. I've been trying to make the subform Invoice pass the company name and Date From info to the query behind the report
The relevate information is
Report: InvoiceCreator
Query: qryInvoiceCreator
Form: Invoice
Fields in Form: Company, DateFrom
I tried to do this two ways... the first, and preferable way, is to double click the Invoice ID. I put this event in the OnDoubleClick:
Private Sub InvoiceID_DblClick(Cancel As Integer)
DoCmd.OpenReport InvoiceCreator, acViewNormal, qryInvoiceCreator, [Forms]![Invoice]![DateFrom], acWindowNormal
End Sub
That gave me this error:
Run-time error "2497"
The action or method requires a Report Name argument.
I tried to append InvoiceCreator on the end in the [subargs] section but that didn't help.
I thought that the DoCmd.OpenReport(InvoiceCreator) should do the trick?
So, I tried to see if Access could help me out a bit =) I used the command button creator wizard and it gave me this:
Private Sub Command33_Click()
On Error GoTo Err_Command33_Click
Dim stDocName As String
stDocName = "InvoiceCreator"
DoCmd.OpenReport stDocName, acPreview
Exit_Command33_Click:
Exit Sub
Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click
End Sub
So, in the hopes of passing the information, I tacked this on to the end of the DoCmd.OpenReport:
, qryInvoiceCreator, [Forms]![Invoice]![DateFrom]
So it looks like this
DoCmd.OpenReport stDocName, acPreview, qryInvoiceCreator, [Forms]![Invoice]![DateFrom]
With the thought that if I could just get the DateFrom field working, I could worry about which company it was later
But that still requests the input boxes from the query - no error, I just still have to enter the information manually.
Anyhow, this is really my first attempt at VBA Code, and I'm missing something. I've searched through the forums to find this much but can't seem to find a way to fix it and make it actually work. Also, how do I add multiple arguments so that it can input Company and Date? Is it And or & or something else?
Thank you in advance!
From this I create invoices and track them. Previously I had to enter the Invoice information in the form. Also, when I created the invoice I had to enter it in pop up boxes.
I did some searches and found out about parameter queries. I've been trying to make the subform Invoice pass the company name and Date From info to the query behind the report
The relevate information is
Report: InvoiceCreator
Query: qryInvoiceCreator
Form: Invoice
Fields in Form: Company, DateFrom
I tried to do this two ways... the first, and preferable way, is to double click the Invoice ID. I put this event in the OnDoubleClick:
Private Sub InvoiceID_DblClick(Cancel As Integer)
DoCmd.OpenReport InvoiceCreator, acViewNormal, qryInvoiceCreator, [Forms]![Invoice]![DateFrom], acWindowNormal
End Sub
That gave me this error:
Run-time error "2497"
The action or method requires a Report Name argument.
I tried to append InvoiceCreator on the end in the [subargs] section but that didn't help.
I thought that the DoCmd.OpenReport(InvoiceCreator) should do the trick?
So, I tried to see if Access could help me out a bit =) I used the command button creator wizard and it gave me this:
Private Sub Command33_Click()
On Error GoTo Err_Command33_Click
Dim stDocName As String
stDocName = "InvoiceCreator"
DoCmd.OpenReport stDocName, acPreview
Exit_Command33_Click:
Exit Sub
Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click
End Sub
So, in the hopes of passing the information, I tacked this on to the end of the DoCmd.OpenReport:
, qryInvoiceCreator, [Forms]![Invoice]![DateFrom]
So it looks like this
DoCmd.OpenReport stDocName, acPreview, qryInvoiceCreator, [Forms]![Invoice]![DateFrom]
With the thought that if I could just get the DateFrom field working, I could worry about which company it was later

But that still requests the input boxes from the query - no error, I just still have to enter the information manually.
Anyhow, this is really my first attempt at VBA Code, and I'm missing something. I've searched through the forums to find this much but can't seem to find a way to fix it and make it actually work. Also, how do I add multiple arguments so that it can input Company and Date? Is it And or & or something else?
Thank you in advance!
Last edited: