S
SAVLO
I have created a form in Access 2003. It includes a option group with 4
option buttons. Each option pointing to a report for a user to preview. All
option buttons are working correctly except for Option 3. This is a List box
from which a user can choose a certain Group. Can anyone explain to me why
Option 3 will not produce the report “Hourly Cost by Groupâ€
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_CmdPreview_Click
Dim strWhereSelectGroup As String
strWhereSelectGroup = "[Asset Group].GroupDescription =
Forms![Print/Preview]!SelectGroup"
Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "Cost per Hour 1st Quarter 2007", PrintMode
Case 2
DoCmd.OpenReport "Hourly Cost by Category", PrintMode
Case 3
If IsNull(Form![Print/Preview]!SelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group", PrintMode, ,
strWhereSelectGroup
End If
Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode
End Select
DoCmd.Close acForm, "Print/Preview"
Exit_CmdPreview_Click:
Exit Sub
Err_CmdPreview_Click:
Resume Exit_CmdPreview_Click
End Sub
Private Sub CmdCancel_Click()
DoCmd.Close
Exit_CmdCancel_Click:
Exit Sub
End Sub
Private Sub CmdPreview_Click()
PrintReports acPreview
End Sub
Private Sub CmdPrint_Click()
PrintReports acNormal
End Sub
Private Sub ReportToPrint_AfterUpdate()
Const constSelectGroup = 3
If Me!ReporttoPrint.Value = constSelectGroup Then
Me!SelectGroup.Enabled = True
Else
Me!SelectGroup.Enabled = False
End If
End Sub
option buttons. Each option pointing to a report for a user to preview. All
option buttons are working correctly except for Option 3. This is a List box
from which a user can choose a certain Group. Can anyone explain to me why
Option 3 will not produce the report “Hourly Cost by Groupâ€
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_CmdPreview_Click
Dim strWhereSelectGroup As String
strWhereSelectGroup = "[Asset Group].GroupDescription =
Forms![Print/Preview]!SelectGroup"
Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "Cost per Hour 1st Quarter 2007", PrintMode
Case 2
DoCmd.OpenReport "Hourly Cost by Category", PrintMode
Case 3
If IsNull(Form![Print/Preview]!SelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group", PrintMode, ,
strWhereSelectGroup
End If
Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode
End Select
DoCmd.Close acForm, "Print/Preview"
Exit_CmdPreview_Click:
Exit Sub
Err_CmdPreview_Click:
Resume Exit_CmdPreview_Click
End Sub
Private Sub CmdCancel_Click()
DoCmd.Close
Exit_CmdCancel_Click:
Exit Sub
End Sub
Private Sub CmdPreview_Click()
PrintReports acPreview
End Sub
Private Sub CmdPrint_Click()
PrintReports acNormal
End Sub
Private Sub ReportToPrint_AfterUpdate()
Const constSelectGroup = 3
If Me!ReporttoPrint.Value = constSelectGroup Then
Me!SelectGroup.Enabled = True
Else
Me!SelectGroup.Enabled = False
End If
End Sub