Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A mess with CheckBoxes for methods of viewing a report

Status
Not open for further replies.

shart00

Technical User
Jun 16, 2003
63
US
3 check boxes named:
1) downloadbox
2) printbox
3) emailbox

Not in a option group since the user may want to download and print or print and email, any combination.

For the on click of the report run button the code starts with:
If Me.Downloadbox = 0 And Me.printbox = 0 And Me.emailbox = 0 Then
MsgBox "Choose any combination of Download/Print/E-mail", , "Option Missing"
Else


Which works great, however it is when it comes down to including the options is where it gets messy. Currently the following has been written but none is working, can someone show me where I went wrong. me.format is for the user to choose 1 = report 2= query

If Me.Format = 1 Then

If Me.Downloadbox = 0 And Me.printbox = 0 And Me.emailbox = 0 Then
MsgBox "Choose any combination of Download/Print/E-mail", , "Option Missing"

ElseIf Me.Downloadbox = 1 And Me.printbox = 0 And Me.emailbox = 0 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.OutputTo acOutputReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.Close acReport, "Summary Time and Attendance Register"

ElseIf Me.Downloadbox = 1 And Me.printbox = 1 And Me.emailbox = 0 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.PrintOut acPrintAll
DoCmd.OutputTo acOutputReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.Close acReport, "Summary Time and Attendance Register"

ElseIf Me.Downloadbox = 1 And Me.printbox = 1 And Me.emailbox = 1 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.PrintOut acPrintAll
DoCmd.OutputTo acOutputReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.SendObject acSendReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.Close acReport, "Summary Time and Attendance Register"

ElseIf Me.Downloadbox = 0 And Me.printbox = 1 And Me.emailbox = 0 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.PrintOut acPrintAll
DoCmd.Close acReport, "Summary Time and Attendance Register"

ElseIf Me.Downloadbox = 0 And Me.printbox = 1 And Me.emailbox = 1 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.PrintOut acPrintAll
DoCmd.SendObject acSendReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.Close acReport, "Summary Time and Attendance Register"

ElseIf Me.Downloadbox = 0 And Me.printbox = 0 And Me.emailbox = 1 Then
DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
DoCmd.SendObject acSendReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
DoCmd.Close acReport, "Summary Time and Attendance Register"

End If

ElseIf Me.Format = 2 Then
DoCmd.OpenForm "SUMMARY TIME AND ATTENDANCE REGISTER", acFormDS, , BuildWhere(Me, "OR")
End If
 
Would it not be simpler to have a discrete instruction for each checkbox.
In reality it doesn't matter if they check 1 or all

1 will download
2 will print
3 will email

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
How are ya shart00 . . . . .

Your going around the block for what you can do at home. Here's the basic I'dea you need:
Code:
[blue]   If Me!downloadbox Then
      [green]'DownLoad code[/green]
   End If

   If Me!printbox Then
     [green]'Print code[/green]
   End If
   
   If Me!emailbox  Then
      [green]'E-Mail code[/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
AceMan1 has the right idea. Something like this:

Code:
If Me.Format = 1 Then

    If Me.Downloadbox = 0 And Me.printbox = 0 And Me.emailbox = 0 Then
        MsgBox "Choose any combination of Download/Print/E-mail", , "Option Missing"

    Else
    
        DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
        
        If (Me.Downloadbox = 1) Then
            DoCmd.OutputTo acOutputReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
        End If
        
        If (Me.printbox = 1) Then
            DoCmd.PrintOut acPrintAll
        End If
        
        If (Me.emailbox = 1) Then
            DoCmd.SendObject acSendReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
        End If
        
        DoCmd.Close acReport, "Summary Time and Attendance Register"

    End If
    
ElseIf Me.Format = 2 Then

    DoCmd.OpenForm "SUMMARY TIME AND ATTENDANCE REGISTER", acFormDS, , BuildWhere(Me, "OR")

End If
 
By the way, since they're check boxes, it should not be equal 1. It should be equal -1. I didn't realize what you had done until after I posted. So, it should look like this:

Code:
If Me.Format = 1 Then

    If Me.Downloadbox = 0 And Me.printbox = 0 And Me.emailbox = 0 Then
        MsgBox "Choose any combination of Download/Print/E-mail", , "Option Missing"

    Else
    
        DoCmd.OpenReport "Summary Time and Attendance Register", acViewPreview, , BuildWhere(Me, "OR")
        
        If (Me.Downloadbox) Then
            DoCmd.OutputTo acOutputReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
        End If
        
        If (Me.printbox) Then
            DoCmd.PrintOut acPrintAll
        End If
        
        If (Me.emailbox) Then
            DoCmd.SendObject acSendReport, "Summary Time and Attendance Register", "Snapshotformat(*.snp)"
        End If
        
        DoCmd.Close acReport, "Summary Time and Attendance Register"

    End If
    
ElseIf Me.Format = 2 Then

    DoCmd.OpenForm "SUMMARY TIME AND ATTENDANCE REGISTER", acFormDS, , BuildWhere(Me, "OR")

End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top