Option Button

  • Thread starter dinadvani via AccessMonster.com
  • Start date
D

dinadvani via AccessMonster.com

Hi,

I want to create a form where I will put in all the report names and then
preview or print or mail report based on the selection.

Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.


Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.

'Dim strWhereCategory As String

'strWhereCategory = "CategoryName = Forms![Sales Reports Dialog]!
SelectCategory"

Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "List of Accounts", PrintMode
Case 2
DoCmd.OpenReport "Quarter-wise Fee Report", PrintMode
Case 3
DoCmd.OpenReport "Account-wise Fee Report", PrintMode
Case 4
DoCmd.OpenReport "Difference in Projected and Actual Report",
PrintMode
End Select
DoCmd.Close acForm, "View Reports"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub



Private Sub Command27_Click()

End Sub

Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub




Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub







Private Sub Command25_Click()
On Error GoTo Err_Command25_Click

Dim stDocName As String

stDocName = "Accountwise Fee Report"
DoCmd.OpenReport stDocName, acNormal

Exit_Command25_Click:
Exit Sub

Err_Command25_Click:
MsgBox Err.Description
Resume Exit_Command25_Click

End Sub


It has 3 reports against which I have an option button, a preview button,
print button and a cancel button.

But none of this button works, also I can select more than 1 option at a time
whereas i want only 1 option to be selected at a time.

Please Help

Any help would be appreciated as i am new to access.

Regards,
Dineh
 
D

dinadvani via AccessMonster.com

Hello,

I am still lost please help.....

I found out the way to select 1 option button at a time.

but the below code is still not working. only the code for cancel click is
working. please verify


Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.

Sub PrintReports(PrintMode As Integer)

On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.


Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "List of Accounts", PrintMode
Case 2
DoCmd.OpenReport "Quarter-wise Report", PrintMode
Case 3
DoCmd.OpenReport "Accountwise Fee Report", PrintMode
Case 4
DoCmd.OpenReport "Difference in Projected and Actual Report",
PrintMode
End Select
DoCmd.Close acForm, "Reporting view"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()

' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click


End Sub

Private Sub Preview_Click()
PrintReports acPreview
End Sub

Private Sub Print_Click()
PrintReports acNormal
End Sub

Thanks for your help

Regards,
D





Hi,

I want to create a form where I will put in all the report names and then
preview or print or mail report based on the selection.

Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.

Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.

'Dim strWhereCategory As String

'strWhereCategory = "CategoryName = Forms![Sales Reports Dialog]!
SelectCategory"

Select Case Me!ReportToPrint
Case 1
DoCmd.OpenReport "List of Accounts", PrintMode
Case 2
DoCmd.OpenReport "Quarter-wise Fee Report", PrintMode
Case 3
DoCmd.OpenReport "Account-wise Fee Report", PrintMode
Case 4
DoCmd.OpenReport "Difference in Projected and Actual Report",
PrintMode
End Select
DoCmd.Close acForm, "View Reports"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub

Private Sub Command27_Click()

End Sub

Private Sub Preview_Click()
' Preview selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acPreview

End Sub

Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub

Private Sub Command25_Click()
On Error GoTo Err_Command25_Click

Dim stDocName As String

stDocName = "Accountwise Fee Report"
DoCmd.OpenReport stDocName, acNormal

Exit_Command25_Click:
Exit Sub

Err_Command25_Click:
MsgBox Err.Description
Resume Exit_Command25_Click

End Sub

It has 3 reports against which I have an option button, a preview button,
print button and a cancel button.

But none of this button works, also I can select more than 1 option at a time
whereas i want only 1 option to be selected at a time.

Please Help

Any help would be appreciated as i am new to access.

Regards,
Dineh
 
D

dinadvani via AccessMonster.com

Please Help... I haven't received any response yet.
Hello,

I am still lost please help.....

I found out the way to select 1 option button at a time.

but the below code is still not working. only the code for cancel click is
working. please verify

Option Compare Database ' Use database order for string comparisons.
Option Explicit ' Requires variables to be declared before they are used.

Sub PrintReports(PrintMode As Integer)

On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click and Print_Click Sub procedures.
' Preview or print report selected in the ReportToPrint option group.
' Then close the Print Sales Reports Dialog form.


Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "List of Accounts", PrintMode
Case 2
DoCmd.OpenReport "Quarter-wise Report", PrintMode
Case 3
DoCmd.OpenReport "Accountwise Fee Report", PrintMode
Case 4
DoCmd.OpenReport "Difference in Projected and Actual Report",
PrintMode
End Select
DoCmd.Close acForm, "Reporting view"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click

End Sub

Private Sub Cancel_Click()

' This code created by Command Button Wizard.
On Error GoTo Err_Cancel_Click

' Close form.
DoCmd.Close

Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

End Sub

Private Sub Preview_Click()
PrintReports acPreview
End Sub

Private Sub Print_Click()
PrintReports acNormal
End Sub

Thanks for your help

Regards,
D
[quoted text clipped - 101 lines]
Regards,
Dineh
 
R

Rick Brandt

dinadvani said:
Please Help... I haven't received any response yet.

What doesn't work? The code is so basic that the only thing I can think is that
your case statement is never satisified. Have you tried stepping through the
code one line at a time to see what is happening?
 
D

dinadvani via AccessMonster.com

Thanks for replying Rick, but i am unable to get in "step into" mode. I am
novice to access and confused on this. Please help.
 

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