Option Group and external Cmds

D

Dave

I have an option group of 6 outside the frame there are 3 Cmd boxes ie,
print, preview, close.

I simply wish to preselect an option and Then click either say a "Print" or
"Preview", "Send" etc (or for that matter cancel).

I have the option group set up, the Cmd boxes etc, But how do I get say the
"Print" Cmd to print the preselected (report), say option 2 etc.??

Any help will be greatly appreciated
Dave
 
A

Al Campagna

Dave,
I think you mean command Button, not box.
I'm assuming there's a diffrent report associated with each number 1-6?

Using the OnClick event of the Print button...

Select Case YourOptionGroupName
Case 1
DoCmd.OpenRreport "rptYourReportName1", acViewPreview
Case 2
DoCmd.OpenRreport "rptYourReportName2", acViewPreview
Case 3
' etc.. for all six possible reports
End Select
 
A

Al Campagna

This is a good example of why posting the same question in different newsgroups is frowned
upon.
Rick Brandt had already answered this question... that you posted in the Access.Forms
group.

Al Campagna
 
G

Graham R Seach

Dave,

I presume the OptionGroup selects the specific report you want to print. In
that case, you can do the following:

1. Create the following enum at module level.
Private Enum PrintTypeEnum
PrintNormal = 1
PrintPreview = 2
PrintCancel = 0
End Enum

2. Create the following procedure in the form:
Public Function PrintReport(intAction As PrintTypeEnum)
Dim strReportName As String

If intAction = PrintTypeEnum.PrintCancel Then Exit Function

Select Case Me.optOptionGroup
Case 1: strReportName = "rptReport1"
Case 2: strReportName = "rptReport2"
Case 3: strReportName = "rptReport3"
Case 4: strReportName = "rptReport4"
Case 5: strReportName = "rptReport5"
Case 6: strReportName = "rptReport6"
Case Else: Exit Function
End Select

DoCmd.OpenReport strReportName, _
Choose(PrintTypeEnum.PrintCancel, _
acViewNormal, acViewPreview)
End Function

3. Then add the following to the OnClick property of the three buttons (the
property, not the event):
...to the [Print] button:
=PrintReport(1)

...to the [Print Preview] button:
=PrintReport(2)

...to the [Cancel] button:
=PrintReport(0)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
D

Dave

Graham
I cannot get my act into gear, the Option Group is outputing Ok , I have a
box reading the numbers 1-6, but the Cmd btns won't function, I have the
enumeration code in a module, the code into the CmdBtns OnClick property
added " =PrintReport(1) and to the onclick prop of the preview Cmd Btn,
=PrintReport(2) ditto for the cancel (0(
I get a message "invalid use of null" or else a msg something like
"PrintReport not recognised"

Could you assist me further?

Regards Dave

Toowoomba Qld

Dave,

I presume the OptionGroup selects the specific report you want to print.
In that case, you can do the following:

1. Create the following enum at module level.
Private Enum PrintTypeEnum
PrintNormal = 1
PrintPreview = 2
PrintCancel = 0
End Enum

2. Create the following procedure in the form:
Public Function PrintReport(intAction As PrintTypeEnum)
Dim strReportName As String

If intAction = PrintTypeEnum.PrintCancel Then Exit Function

Select Case Me.optOptionGroup
Case 1: strReportName = "rptReport1"
Case 2: strReportName = "rptReport2"
Case 3: strReportName = "rptReport3"
Case 4: strReportName = "rptReport4"
Case 5: strReportName = "rptReport5"
Case 6: strReportName = "rptReport6"
Case Else: Exit Function
End Select

DoCmd.OpenReport strReportName, _
Choose(PrintTypeEnum.PrintCancel, _
acViewNormal, acViewPreview)
End Function

3. Then add the following to the OnClick property of the three buttons
(the property, not the event):
...to the [Print] button:
=PrintReport(1)

...to the [Print Preview] button:
=PrintReport(2)

...to the [Cancel] button:
=PrintReport(0)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
I have an option group of 6 outside the frame there are 3 Cmd boxes ie,
print, preview, close.

I simply wish to preselect an option and Then click either say a "Print"
or
"Preview", "Send" etc (or for that matter cancel).

I have the option group set up, the Cmd boxes etc, But how do I get say
the
"Print" Cmd to print the preselected (report), say option 2 etc.??

Any help will be greatly appreciated
Dave
 
G

Graham R Seach

Dave,

I don't know why you'd be getting an "Invalid use of Null" error, but I did
notice an error in the code I gave you. Change the code as follows, and let
us know how it goes.
DoCmd.OpenReport strReportName, _
Choose(intAction , acViewNormal, acViewPreview)

If you get any more errors, let us know the error text, and the line that
caused it. Please respond in the newsgroups, not to my email address.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
Graham
I cannot get my act into gear, the Option Group is outputing Ok , I have a
box reading the numbers 1-6, but the Cmd btns won't function, I have the
enumeration code in a module, the code into the CmdBtns OnClick property
added " =PrintReport(1) and to the onclick prop of the preview Cmd Btn,
=PrintReport(2) ditto for the cancel (0(
I get a message "invalid use of null" or else a msg something like
"PrintReport not recognised"

Could you assist me further?

Regards Dave

Toowoomba Qld

Dave,

I presume the OptionGroup selects the specific report you want to print.
In that case, you can do the following:

1. Create the following enum at module level.
Private Enum PrintTypeEnum
PrintNormal = 1
PrintPreview = 2
PrintCancel = 0
End Enum

2. Create the following procedure in the form:
Public Function PrintReport(intAction As PrintTypeEnum)
Dim strReportName As String

If intAction = PrintTypeEnum.PrintCancel Then Exit Function

Select Case Me.optOptionGroup
Case 1: strReportName = "rptReport1"
Case 2: strReportName = "rptReport2"
Case 3: strReportName = "rptReport3"
Case 4: strReportName = "rptReport4"
Case 5: strReportName = "rptReport5"
Case 6: strReportName = "rptReport6"
Case Else: Exit Function
End Select

DoCmd.OpenReport strReportName, _
Choose(PrintTypeEnum.PrintCancel, _
acViewNormal, acViewPreview)
End Function

3. Then add the following to the OnClick property of the three buttons
(the property, not the event):
...to the [Print] button:
=PrintReport(1)

...to the [Print Preview] button:
=PrintReport(2)

...to the [Cancel] button:
=PrintReport(0)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
I have an option group of 6 outside the frame there are 3 Cmd boxes ie,
print, preview, close.

I simply wish to preselect an option and Then click either say a "Print"
or
"Preview", "Send" etc (or for that matter cancel).

I have the option group set up, the Cmd boxes etc, But how do I get say
the
"Print" Cmd to print the preselected (report), say option 2 etc.??

Any help will be greatly appreciated
Dave
 
D

Dave

Many thanks for the Cmd Btns, all working fine with change of code.

Could I ask one thing further. I have a command btn which I wish to use the
options group output code, but then this btn to take the selected report
from the ops group and drop it into word (for edit etc)
Dave

Graham R Seach said:
Dave,

I don't know why you'd be getting an "Invalid use of Null" error, but I
did notice an error in the code I gave you. Change the code as follows,
and let us know how it goes.
DoCmd.OpenReport strReportName, _
Choose(intAction , acViewNormal, acViewPreview)

If you get any more errors, let us know the error text, and the line that
caused it. Please respond in the newsgroups, not to my email address.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
Graham
I cannot get my act into gear, the Option Group is outputing Ok , I have
a box reading the numbers 1-6, but the Cmd btns won't function, I have
the enumeration code in a module, the code into the CmdBtns OnClick
property added " =PrintReport(1) and to the onclick prop of the preview
Cmd Btn, =PrintReport(2) ditto for the cancel (0(
I get a message "invalid use of null" or else a msg something like
"PrintReport not recognised"

Could you assist me further?

Regards Dave

Toowoomba Qld

Dave,

I presume the OptionGroup selects the specific report you want to print.
In that case, you can do the following:

1. Create the following enum at module level.
Private Enum PrintTypeEnum
PrintNormal = 1
PrintPreview = 2
PrintCancel = 0
End Enum

2. Create the following procedure in the form:
Public Function PrintReport(intAction As PrintTypeEnum)
Dim strReportName As String

If intAction = PrintTypeEnum.PrintCancel Then Exit Function

Select Case Me.optOptionGroup
Case 1: strReportName = "rptReport1"
Case 2: strReportName = "rptReport2"
Case 3: strReportName = "rptReport3"
Case 4: strReportName = "rptReport4"
Case 5: strReportName = "rptReport5"
Case 6: strReportName = "rptReport6"
Case Else: Exit Function
End Select

DoCmd.OpenReport strReportName, _
Choose(PrintTypeEnum.PrintCancel, _
acViewNormal, acViewPreview)
End Function

3. Then add the following to the OnClick property of the three buttons
(the property, not the event):
...to the [Print] button:
=PrintReport(1)

...to the [Print Preview] button:
=PrintReport(2)

...to the [Cancel] button:
=PrintReport(0)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

I have an option group of 6 outside the frame there are 3 Cmd boxes ie,
print, preview, close.

I simply wish to preselect an option and Then click either say a
"Print" or
"Preview", "Send" etc (or for that matter cancel).

I have the option group set up, the Cmd boxes etc, But how do I get say
the
"Print" Cmd to print the preselected (report), say option 2 etc.??

Any help will be greatly appreciated
Dave
 
G

Graham R Seach

Dave,

The easiest way is to publish it as RTF. Once done, you can open it with
Word:
DoCmd.OutputTo acOutputReport, strReportName, acFormatRTF, strFileName

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
Many thanks for the Cmd Btns, all working fine with change of code.

Could I ask one thing further. I have a command btn which I wish to use
the options group output code, but then this btn to take the selected
report from the ops group and drop it into word (for edit etc)
Dave

Graham R Seach said:
Dave,

I don't know why you'd be getting an "Invalid use of Null" error, but I
did notice an error in the code I gave you. Change the code as follows,
and let us know how it goes.
DoCmd.OpenReport strReportName, _
Choose(intAction , acViewNormal, acViewPreview)

If you get any more errors, let us know the error text, and the line that
caused it. Please respond in the newsgroups, not to my email address.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Dave said:
Graham
I cannot get my act into gear, the Option Group is outputing Ok , I have
a box reading the numbers 1-6, but the Cmd btns won't function, I have
the enumeration code in a module, the code into the CmdBtns OnClick
property added " =PrintReport(1) and to the onclick prop of the preview
Cmd Btn, =PrintReport(2) ditto for the cancel (0(
I get a message "invalid use of null" or else a msg something like
"PrintReport not recognised"

Could you assist me further?

Regards Dave

Toowoomba Qld


Dave,

I presume the OptionGroup selects the specific report you want to
print. In that case, you can do the following:

1. Create the following enum at module level.
Private Enum PrintTypeEnum
PrintNormal = 1
PrintPreview = 2
PrintCancel = 0
End Enum

2. Create the following procedure in the form:
Public Function PrintReport(intAction As PrintTypeEnum)
Dim strReportName As String

If intAction = PrintTypeEnum.PrintCancel Then Exit Function

Select Case Me.optOptionGroup
Case 1: strReportName = "rptReport1"
Case 2: strReportName = "rptReport2"
Case 3: strReportName = "rptReport3"
Case 4: strReportName = "rptReport4"
Case 5: strReportName = "rptReport5"
Case 6: strReportName = "rptReport6"
Case Else: Exit Function
End Select

DoCmd.OpenReport strReportName, _
Choose(PrintTypeEnum.PrintCancel, _
acViewNormal, acViewPreview)
End Function

3. Then add the following to the OnClick property of the three buttons
(the property, not the event):
...to the [Print] button:
=PrintReport(1)

...to the [Print Preview] button:
=PrintReport(2)

...to the [Cancel] button:
=PrintReport(0)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

I have an option group of 6 outside the frame there are 3 Cmd boxes ie,
print, preview, close.

I simply wish to preselect an option and Then click either say a
"Print" or
"Preview", "Send" etc (or for that matter cancel).

I have the option group set up, the Cmd boxes etc, But how do I get
say the
"Print" Cmd to print the preselected (report), say option 2 etc.??

Any help will be greatly appreciated
Dave
 

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

Top