Link to home
Start Free TrialLog in
Avatar of HarringtonBell
HarringtonBellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Print Report Using Query

I am using the following code with a button on my switchboard

It is supposed to prompt the user for a number (in this case a receipt number) and then parses the reciept number to the report and prints out the duplicate receipt. However I have tried many variations and get either a syntax error or it repeats the most current receipt.

I would appreciate it if someone could help me fix this code please
Dim MyValue As Variant
MyValue = InputBox("Type in the receipt number, to be printed.", "Print a duplicate receipt")
If MyValue = "" Then
MsgBox "The duplicate receipt is cancelled."
Exit Function
 
End If
 
DoCmd.OpenReport "dupreceipt", acViewNormal, , "ReceiptNo = MyValue"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HarringtonBell

ASKER

When I change that line my report prints out but is Blank, almost as if its not picking up with record.

Do you have any other ideas?
What data type is the receipt number?
receipt type is a number field
I am awarding these points since the answer is correct, however the reason it wasn't working is because the form is linked to a qry that was had specific criteria attached the receipt field.  I now have it working correctly though
I am awarding these points since the answer is correct, however the reason it wasn't working is because the form is linked to a qry that was had specific criteria attached the receipt field.  I now have it working correctly though