Print a report using a query with a paramenter

naym

Registered User.
Local time
Today, 22:11
Joined
Aug 30, 2006
Messages
47
Hi all,

I am wandering if someone can give me some help on this,
Baiscally i have a form with order and order details tabels i have a query i can run and brings up the order and all the order details based on the order id.

The problem is that i have created the report and i have addeda button to the form but when i sent it to print it the paramenter box comes up asking for the order id, as i am suing a touch screen it isnt a really good method of printing, so is there anyway i can write some code to print the report based on the query and get the current order number from the form??

I Hope this makes sense and someone can give me a hand on this

Thanks

Regards

Naym
 
I would think you could simply use something like the following as the parameter in the reports query:

forms!frmMain!myRecordNumberField

???
 
Hi,

Yes i have done that i have set the parameter in my query as :
[ Forms]![Orders]![Order id]

and i have set the report up also and added a button to the form with the follwing code (i have tried a few different methods:
Private Sub Command106_Click()

Form_Orders.ODS.SetFocus
Dim stDocName As String
stDocName = "RptTakeaway"
DoCmd.OpenReport stDocName, acNormal

The above is one method another method i did was
Private Sub CmdPrint_Click()
Dim stDocName As String, myvar
Me.Order_Type.SetFocus
tp = Me.Order_Type.Text
If tp = "Takeaway" Then
stDocName = "RptTakeaway"

DoCmd.RunCommand acCmdRecordsGoToFirst

DoCmd.OpenReport stDocName, acViewNormal

End If
End If
End Sub

Witha ll these methods i will print the report but before it does it asks the paramenter query of which order number to i want to print so i have to type the order id.
Is there a way i can get the order id into the parameter by code??

Again help on this would be much appreciated.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom