Hi,
Before i start, i just wanna say that i am new to Access & VBA and please excuse me if iask stupid questions.
Right here's what i need help with:
Basically I have a report which requires the user to type in the OrderID when the user attempts to open the report. This is what pops up below:
That is fine, but what i want is a button on a form, for which when i click on it, it loads up the report 'Invoice' with the paramater requested above as the record that i am currently viewing.
For example If i am viewing a record with 'OrderID' as 10348 and i click the command button, it will open up the report with the paramater value as 10348.
I hope you get what i mean, i am getting frustrated about how to do this.
This is what i got from another website, i am probably doijng it wrong.
Any help would be much appreciated, i am sure this is very easy to do.
Thanks, i am waiting patiently for a response.
Before i start, i just wanna say that i am new to Access & VBA and please excuse me if iask stupid questions.
Right here's what i need help with:
Basically I have a report which requires the user to type in the OrderID when the user attempts to open the report. This is what pops up below:
That is fine, but what i want is a button on a form, for which when i click on it, it loads up the report 'Invoice' with the paramater requested above as the record that i am currently viewing.
For example If i am viewing a record with 'OrderID' as 10348 and i click the command button, it will open up the report with the paramater value as 10348.
I hope you get what i mean, i am getting frustrated about how to do this.
This is what i got from another website, i am probably doijng it wrong.
Code:
Private Sub cmdPrintPreview_Click()
Dim strReportName As String
Dim strCriteria As String
If NewRecord Then
MsgBox "This record contains no data. Please select a record to print or Save this record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "Invoice"
strCriteria = "[Forms]![Sales]![OrderID]= " & Me![OrderID]
'strCriteria = "[Forms]![Sales]![OrderID]= " & Me![OrderID] & "'"
'strCriteria = "[lngSalespersonID]='" & Me![lngSalespersonID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If
End Sub
Any help would be much appreciated, i am sure this is very easy to do.
Thanks, i am waiting patiently for a response.