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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event procedure help 1

Status
Not open for further replies.

matty1404

MIS
Feb 12, 2007
74
US
I need to put an event procedure in my report. I already have one for the user to input the date when it opens. First, can I put more than one event procedure for on open. Last, how do I create a yes no box that would ask the user if they want to gray shade the records or not??
 
IMHO, don't prompt users for anything in the On Open event or anywhere else. All user interaction should come from controls on forms.

I would use a check box on your form to allow the user to set whether the report should be shaded. Other criteria/parameters should be entered into other controls on the form.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
This is a very simple program though. What we are prompting for now is just enter the date. The report gets sent to a faxing program. They use a form to run the report, then they get prompted. It works well how they run it now. I just need some code so I can prompt for a user yes or no, then if yes do this, if no do this.
 
You can create a variable in the report declarations section and set the value of the variable in the On Open event of the report. Your code might look like:
Code:
Option Compare Database
Option Explicit
Dim booShade As Boolean

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If booShade Then
        If Me.Section(0).BackColor = 12632256 Then
            Me.Section(0).BackColor = vbWhite
         Else
            Me.Section(0).BackColor = 12632256
        End If
    End If
End Sub

Private Sub Report_Open(Cancel As Integer)
    booShade = MsgBox("Do you want to shade?", _
        vbQuestion + vbYesNo, "Shade It") = vbYes
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Wow, that worked perfectly, thanks a lot, I appreciate that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top