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

LVL 1
HarringtonBellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
If the receipt number is a text field then..

DoCmd.OpenReport "dupreceipt", acViewNormal, , "ReceiptNo = '" & MyValue & "'"


If the receipt number is a number field then..

DoCmd.OpenReport "dupreceipt", acViewNormal, , "ReceiptNo = " & MyValue
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HarringtonBellAuthor Commented:
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?
0
peter57rCommented:
What data type is the receipt number?
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

HarringtonBellAuthor Commented:
receipt type is a number field
0
HarringtonBellAuthor Commented:
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
0
HarringtonBellAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.