Issue with Ms access Reports
I am trying to preview a report of the current tracking number which is on the main form(main form name is:frmReviewReleaseLogWrapper) by using a command butto开发者_Python百科n. Each tracking number has different part numbers, so each tracking number has many records in the DB table (Depending upon the number of partnumbers, that is each partnumber has a record) I wrote the following code and it is not working, It is just displaying report name and column names and not the records.
Code is as follows:
Private Sub Command225_Click()
On Error GoTo Err_Command225_Click
Dim stDocName As String
DoCmd.OpenReport "rptEventLog", acPreview, , "[TrackingNumber] = Forms!frmReviewReleaseLogWrapper"
Exit_Command225_Click:
Exit Sub
Err_Command225_Click:
MsgBox Err.Description
Resume Exit_Command225_Click
End Sub
What's the name of the control on the frmReviewReleaseLogWrapper form that contains the tracking number? You need to reference it in your OpenReport statement, like so:
DoCmd.OpenReport "rptEventLog", acPreview, , _
"[TrackingNumber] = Forms!frmReviewReleaseLogWrapper!txtField"
Incidentally, you might do better to give your command button a name that reflects its actual function, so it'll be easier to find later.
精彩评论