Rhodes7292
New member
- Local time
- Today, 09:44
- Joined
- Nov 7, 2012
- Messages
- 4
Hi Guys
I am trying to place a Switchboard into my Access 2003 DB and have based it on the Northwind version with amendments to suit my needs.
I have amended the code to reflect the forms contents but it keeps coming up with the error The Expression on click you entered as the event property setting produced the following error: Duplicate option statement.
though running through the code I can't see any obvious duplication.
Option Compare Database
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
strWhereCategory = "CategoryName = Forms![Sales Reports Dialog]!SelectCategory"
Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "Product Sales", PrintMode
Case 2
DoCmd.OpenReport "Sales by County", PrintMode
Case 3
DoCmd.OpenReport "Sales by County Chart", PrintMode
Case 4
DoCmd.OpenReport "Sales by Year", PrintMode
Case 5
DoCmd.OpenReport "Summary of Sales by Quarter", PrintMode
Case 6
DoCmd.OpenReport "Summary of Sales by Year", PrintMode
Case 7
If IsNull(Forms![Sales Reports Dialog]!SelectCategory) Then
DoCmd.OpenReport "Sales by Category", PrintMode
Else
DoCmd.OpenReport "Sales by Category", PrintMode, , strWhereCategory
End If
End Select
DoCmd.Close acForm, "Sales Reports Dialog"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click
' Close form.
DoCmd.Close
Exit_Cancel_Click:
Exit Sub
Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click
End Sub
Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub
Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acNormal
End Sub
Private Sub ReportToPrint_AfterUpdate()
' Enable SelectCategory combo box if user selected Sales by Category
' report.
Const conSalesByCategory = 7
If Me!ReportToPrint.Value = conSalesByCategory Then
Me!SelectCategory.Enabled = True
Else
Me!SelectCategory.Enabled = False
End If
End Sub
Does anyone know what I'm doing wrong?
Thanks
Mark
I am trying to place a Switchboard into my Access 2003 DB and have based it on the Northwind version with amendments to suit my needs.
I have amended the code to reflect the forms contents but it keeps coming up with the error The Expression on click you entered as the event property setting produced the following error: Duplicate option statement.
though running through the code I can't see any obvious duplication.
Option Compare Database
Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.
Dim strWhereCategory As String
strWhereCategory = "CategoryName = Forms![Sales Reports Dialog]!SelectCategory"
Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "Product Sales", PrintMode
Case 2
DoCmd.OpenReport "Sales by County", PrintMode
Case 3
DoCmd.OpenReport "Sales by County Chart", PrintMode
Case 4
DoCmd.OpenReport "Sales by Year", PrintMode
Case 5
DoCmd.OpenReport "Summary of Sales by Quarter", PrintMode
Case 6
DoCmd.OpenReport "Summary of Sales by Year", PrintMode
Case 7
If IsNull(Forms![Sales Reports Dialog]!SelectCategory) Then
DoCmd.OpenReport "Sales by Category", PrintMode
Else
DoCmd.OpenReport "Sales by Category", PrintMode, , strWhereCategory
End If
End Select
DoCmd.Close acForm, "Sales Reports Dialog"
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click
' Close form.
DoCmd.Close
Exit_Cancel_Click:
Exit Sub
Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click
End Sub
Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acPreview
End Sub
Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.
PrintReports acNormal
End Sub
Private Sub ReportToPrint_AfterUpdate()
' Enable SelectCategory combo box if user selected Sales by Category
' report.
Const conSalesByCategory = 7
If Me!ReportToPrint.Value = conSalesByCategory Then
Me!SelectCategory.Enabled = True
Else
Me!SelectCategory.Enabled = False
End If
End Sub
Does anyone know what I'm doing wrong?
Thanks
Mark