I tried that and it beeps. So now we know the problem lies with the report
call. In my report properties I have the following filter:
[GroupDescription]=!Forms [Print/Preview]![SelectGroup]
The GroupDescription is the name of the field in the underlying table "Asset
Group"
Print/Preview is the name of the Form
SelectGroup is the name of the List Box
Thank You,
:
Case 3
Beep
If IsNull(Form![Print/Preview]!SelectGroup) Then.....
Lookup Beep Method in Help...
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
You are correct all the Select Case statements work except #3.
I've never used "BEEP" were do I place that.. at the end of Case 3?
:
OK... right now, I'm assuming that all the SelectCase statements work... except
for
#3.
I originally wanted to remove the Asset Group from the Where argument, but I
missed
it.
It also appears, in your latest post, that the Where argument really has no
"argument"
strWhereSelectGroup = "[Asset Group].GroupDescription
Forms![Print/Preview]!SelectGroup"
I think you "typo-ed" this, and you really want... (your original post had the =
sign)
and... dropping the "[Asset Group]."
"[GroupDescription] = Forms![Print/Preview]!SelectGroup"
This should be a legitimate Where argument given that... GroupDescription is
in the report query, and has values that match the SelectGroup value on the
form.
Try this trick... put a Beep in Case #3. If you setup for a #3 result, and the
code
beeps...
then you know that the problems lies with the report "call", or the query/report.
I wrote...
What are you doing with the "PrintMode?" in your OpenReport code. Can you
drop
that
for now while we get the "basics" working.
Please remove the PrintMode for now.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
There is no error message, it just doesn't do anything when I choose from the
list. The other reports open just fine. Here is the entire code including
the print and the preview protion. Thanks for your help.
Option Compare Database
Option Explicit
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()
'Close Form
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()
'Enable Select Group list if user selected Hourly Cost by Group
Const constSelectGroup = 3
If Me!ReporttoPrint.Value = constSelectGroup Then
Me!SelectGroup.Enabled = True
Else
Me!SelectGroup.Enabled = False
End If
End Sub
:
Salvo,
I'm finally able to get back to my project. I tried your suggestion but it
did not solve the problem. Any other suggestions?
What do you mean by "still doesn't work". Any error messages?
Whenever you say your code doesn't worK, Cut & Paste your code in your post
(the
whole
procedure).
What are you doing with the "PrintMode?" in your OpenReport code. Can you
drop
that
for now while we get the "basics" working.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
I'm finally able to get back to my project. I tried your suggestion but it
did not solve the problem. Any other suggestions?
:
Salvo,
Try... (all on one line), and assuming GroupDescription is text...
strWhereSelectGroup = "[Asset Group].GroupDescription = '" &
SelectGroup
"'"
(with apostrophes expanded for clarity... don't use this)
strWhereSelectGroup = "[Asset Group].GroupDescription = ' " &
SelectGroup
" '
"
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
I have created an option group on a form with 4 buttons all are pointing
to a
report. 3 are working properly Option 4 invokes a list box for a user to
choose an particular group to include in the report. I believe there
needs
to be something in the properties of the report but I'm not sure what.
Can
anyone help?
The following is the code I used:
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