Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command button/option group code not executing properly 1

Status
Not open for further replies.

Fredgarner

Technical User
Jul 21, 2005
29
GB
Does anyone know why this is returning the error message 'Compile error: Variable not defined'?

Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.


Private Sub Detail_Click()

End Sub
Private Sub Command56_Click()
On Error GoTo Err_Command56_Click

Dim stDocName As String

If Opt_Reports = 1 Then
lcReportName = "Shareholdings (by intermediary)"
ElseIf Opt_Reports = 2 Then
lcReportName = "Shareholdings (by share class)"
ElseIf Opt_Reports = 3 Then
lcReportName = "Shareholdings (by shareholder)"
Else
lcReportName = "" 'Force Error
End If

DoCmd.OpenReport stDocName, acPreview

Exit_Command56_Click:
Exit Sub

Err_Command56_Click:
MsgBox Err.Description
Resume Exit_Command56_Click

End Sub
 

you need to add

Dim lcReportName as string


at the top!
 

Oh, and change the line to

DoCmd.OpenReport lcReportName, acPreview

 
And for reports, the real constant is acViewPreview
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top