Trouble with Report Preview Button on sub form

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Sirs,

I have a button to call a report preview for a worksheet report which
is named worksheet_report. It works fine on the main form. I need to
move this button to a sub form which is named menu-9.

Private Sub Command2_Click()


Dim stDocName As String
Dim strWhere As String
If Me.NewRecord Then
MsgBox "Select a record to print"
Else
stDocName = "worksheet_report"
strWhere = "[ID]=" & Me![ID]
DoCmd.OpenReport stDocName, acPreview, , strWhere
End If


End Sub

This code is for the worksheet report button on the main form. What do
I need to change to get it to work on the sub menu form?
 
Robert said:
Sirs,

I have a button to call a report preview for a worksheet report which
is named worksheet_report. It works fine on the main form. I need to
move this button to a sub form which is named menu-9.

Private Sub Command2_Click()


Dim stDocName As String
Dim strWhere As String
If Me.NewRecord Then
MsgBox "Select a record to print"
Else
stDocName = "worksheet_report"
strWhere = "[ID]=" & Me![ID]
DoCmd.OpenReport stDocName, acPreview, , strWhere
End If


End Sub

This code is for the worksheet report button on the main form. What do
I need to change to get it to work on the sub menu form?


It's not obvious that anything needs to change. What error message do you
get when you click the button? Does the subform have a field called "ID"?
 
Back
Top