Option Group

G

Guest

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
 
A

Al Campagna

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."
 
G

Guest

I will try this and let you know, Thanks

Al Campagna said:
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."


SAVLO said:
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
 
G

Guest

I'm finally able to get back to my project. I tried your suggestion but it
did not solve the problem. Any other suggestions?

Al Campagna said:
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."


SAVLO said:
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
 
A

Al Campagna

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."


SAVLO said:
I'm finally able to get back to my project. I tried your suggestion but it
did not solve the problem. Any other suggestions?

Al Campagna said:
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."


SAVLO said:
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
 
G

Guest

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


Al Campagna said:
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."


SAVLO said:
I'm finally able to get back to my project. I tried your suggestion but it
did not solve the problem. Any other suggestions?

Al Campagna said:
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
 
A

Al Campagna

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...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."



SAVLO said:
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


Al Campagna said:
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."


SAVLO said:
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
 
G

Guest

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?

Al Campagna said:
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...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."



SAVLO said:
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


Al Campagna said:
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
 
A

Al Campagna

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."

SAVLO said:
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?

Al Campagna said:
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."



SAVLO said:
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
 
G

Guest

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,

Al Campagna said:
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."

SAVLO said:
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?

Al Campagna said:
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
 
A

Al Campagna

In this instance, a report Filter is not necessary, besides the fact that the Filter
syntax you provided is incorrect.
You used a Where statement in your OpenReport from the form, so you need no other
criteria for GroupDescription, in either the report and the query behind the report. The
OpenReport Where argument provides the filter for the report.
Remove that Filter on the form, and any other GroupDescription criteria you may have
in the report query, and use just the Where argument to control the report output.
The form must remain open while the report runs. When you close the report you will
return to the "calling" form.

--
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."

SAVLO said:
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,

Al Campagna said:
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."

SAVLO said:
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
 
G

Guest

I removed the filter from the report but it still won't open the report. The
report is generated by 6 Sequential queries. At this point I'm frustrated
but I'm checking all of the queries and all the properties in the report. I
appreciate your patience. I'll let you know what I find and if I can get
this to work. There is no reason why it shouldn't, I just have to find that
one little error.
Thanks

Al Campagna said:
In this instance, a report Filter is not necessary, besides the fact that the Filter
syntax you provided is incorrect.
You used a Where statement in your OpenReport from the form, so you need no other
criteria for GroupDescription, in either the report and the query behind the report. The
OpenReport Where argument provides the filter for the report.
Remove that Filter on the form, and any other GroupDescription criteria you may have
in the report query, and use just the Where argument to control the report output.
The form must remain open while the report runs. When you close the report you will
return to the "calling" form.

--
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."

SAVLO said:
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,

Al Campagna said:
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
 
A

Al Campagna

Salvo,
Yes... I think your on your own from here. There's not much chance of my assisting you
with 6 queries.
Why don't you just try to use the one table that has GroupDescription in it, and a very
simple report, to see if your OpenReport will properly filter those records.
Then start adding your other tables/queries... testing as you go.
Good luck... I'll check this thread from time to time.
--
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."

SAVLO said:
I removed the filter from the report but it still won't open the report. The
report is generated by 6 Sequential queries. At this point I'm frustrated
but I'm checking all of the queries and all the properties in the report. I
appreciate your patience. I'll let you know what I find and if I can get
this to work. There is no reason why it shouldn't, I just have to find that
one little error.
Thanks

Al Campagna said:
In this instance, a report Filter is not necessary, besides the fact that the Filter
syntax you provided is incorrect.
You used a Where statement in your OpenReport from the form, so you need no other
criteria for GroupDescription, in either the report and the query behind the report.
The
OpenReport Where argument provides the filter for the report.
Remove that Filter on the form, and any other GroupDescription criteria you may
have
in the report query, and use just the Where argument to control the report output.
The form must remain open while the report runs. When you close the report you
will
return to the "calling" form.

--
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."

SAVLO said:
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
 
G

Guest

Al,
I did what you suggested and I'm one step closer. I created a very simple
query using 2 tables, one being the Group table. Then did a simple report.
The first part of Case 3 now opens the report (which it did not before) but
when I try to select from the list it does nothing. Do I have an error in
the Dim expression?
I used the word Group in the Dim strWhere but it's not tied to anything.
I'm just identifiying the field "Group Description" as text.

Dim strWhereGroup As String

strWhereGroup = "Group Description = Forms![Print or
View]!ListSelectGroup"
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(Forms![Print or View]!ListSelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group test", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group test", strWhereGroup
End If

Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode

End Select

Al Campagna said:
Salvo,
Yes... I think your on your own from here. There's not much chance of my assisting you
with 6 queries.
Why don't you just try to use the one table that has GroupDescription in it, and a very
simple report, to see if your OpenReport will properly filter those records.
Then start adding your other tables/queries... testing as you go.
Good luck... I'll check this thread from time to time.
--
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."

SAVLO said:
I removed the filter from the report but it still won't open the report. The
report is generated by 6 Sequential queries. At this point I'm frustrated
but I'm checking all of the queries and all the properties in the report. I
appreciate your patience. I'll let you know what I find and if I can get
this to work. There is no reason why it shouldn't, I just have to find that
one little error.
Thanks

Al Campagna said:
In this instance, a report Filter is not necessary, besides the fact that the Filter
syntax you provided is incorrect.
You used a Where statement in your OpenReport from the form, so you need no other
criteria for GroupDescription, in either the report and the query behind the report.
The
OpenReport Where argument provides the filter for the report.
Remove that Filter on the form, and any other GroupDescription criteria you may
have
in the report query, and use just the Where argument to control the report output.
The form must remain open while the report runs. When you close the report you
will
return to the "calling" form.

--
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 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
 
A

Al Campagna

Salvo,
First, I asked you to drop the PrintMode. Please do so.
You don't indicate any value for PrintMode, so as far as I can tell, it's not doing
anything
If acViewPreview is included in the OpenReport argument, the report will open in
Preview mode... if not, the default is "print immediately."

Secondly, you have the Where argument in the wrong place.
Read OpenReport Syntax From Help....
DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

You have the Where arguement in the FilterName argument... The FilterName argument is
for saved queries, not for an SQL Where statement.
Notice the 2 commas in the 2nd portion, where (because you did not signify an
arguement) the default is "print immediately"
Case 3
If IsNull(Forms![Print or View]!ListSelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group test", acViewPreview
Else
DoCmd.OpenReport "Hourly Cost by Group test", , strWhereGroup
End If
--
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."

SAVLO said:
Al,
I did what you suggested and I'm one step closer. I created a very simple
query using 2 tables, one being the Group table. Then did a simple report.
The first part of Case 3 now opens the report (which it did not before) but
when I try to select from the list it does nothing. Do I have an error in
the Dim expression?
I used the word Group in the Dim strWhere but it's not tied to anything.
I'm just identifiying the field "Group Description" as text.

Dim strWhereGroup As String

strWhereGroup = "Group Description = Forms![Print or
View]!ListSelectGroup"
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(Forms![Print or View]!ListSelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group test", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group test", strWhereGroup
End If

Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode

End Select

Al Campagna said:
Salvo,
Yes... I think your on your own from here. There's not much chance of my assisting
you
with 6 queries.
Why don't you just try to use the one table that has GroupDescription in it, and a
very
simple report, to see if your OpenReport will properly filter those records.
Then start adding your other tables/queries... testing as you go.
Good luck... I'll check this thread from time to time.
--
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."

SAVLO said:
I removed the filter from the report but it still won't open the report. The
report is generated by 6 Sequential queries. At this point I'm frustrated
but I'm checking all of the queries and all the properties in the report. I
appreciate your patience. I'll let you know what I find and if I can get
this to work. There is no reason why it shouldn't, I just have to find that
one little error.
Thanks

:

In this instance, a report Filter is not necessary, besides the fact that the
Filter
syntax you provided is incorrect.
You used a Where statement in your OpenReport from the form, so you need no other
criteria for GroupDescription, in either the report and the query behind the report.
The
OpenReport Where argument provides the filter for the report.
Remove that Filter on the form, and any other GroupDescription criteria you may
have
in the report query, and use just the Where argument to control the report output.
The form must remain open while the report runs. When you close the report you
will
return to the "calling" form.

--
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 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top