VB Code and a report with a paramerter query

rlischer

New member
Local time
Yesterday, 19:26
Joined
Oct 22, 2007
Messages
5
I am new to VB and I am stuck. I am trying to pass an invoice number to a report that has a parameter query behind it. I get all invoices and not the one I enter. Can somebody see what I am doing wrong? The database in "addata.mdb", the report is "rptInvoice" Thanks!

Dim DBPath As String
Dim myparameter As String
Dim mystring As String

myparameter = InputBox("Enter Invoice Number ?")


Dim appAccess As Object
Set appAccess = CreateObject("Access.Application.11")
DBPath = "D:\addata.mdb"
appAccess.OpenCurrentDatabase DBPath
appAccess.DoCmd.OpenReport "rptInvoice", 2, myparameter
 
The proper syntax for a wherecondition would be:

"FieldName = 123"

The value would have to be surrounded by single quotes if it's text.
 
The proper syntax for a wherecondition would be:

"FieldName = 123"

The value would have to be surrounded by single quotes if it's text.

ok, Does the Access Query qryInvoice need to have a paramerter in it at all? Like [inv_number] or [parameter] ?

Thanks
 
No, you can pass a parameter in the wherecondition argument of OpenReport.
 
No, you can pass a parameter in the wherecondition argument of OpenReport.

Thanks. Even if I hard code the invoice number like below, I still get them all and not the one I wanted:

appAccess.DoCmd.OpenReport "rptInvoice", 2, "inv_number = 'CT-HIC024'"
 
You have it in the Filter argument. Try:

appAccess.DoCmd.OpenReport "rptInvoice", 2,, "inv_number = 'CT-HIC024'"
 
You have it in the Filter argument. Try:

appAccess.DoCmd.OpenReport "rptInvoice", 2,, "inv_number = 'CT-HIC024'"

Thanks very much! I have been racking my brains all day and it was just one missing comma!
 
No problem. It's always the seemingly insignificant things that trip you up. :p
 

Users who are viewing this thread

Back
Top Bottom