Simple if structure - if checkbox is ticked, then open the form - how?

Sharky II

Registered User.
Local time
Today, 14:08
Joined
Aug 21, 2003
Messages
354
Hi

I'm trying to do something like this:

Code:
Private Sub chkLaunchTableBox()
    If (Me![chkLaunchTableBox] = -1) Then
        DoCmd.OpenQuery "qryMyQuery"
    End If

End Sub

Sorry i am a programmer but not a vb programmer :) Can anyone help me out with the syntax? Do i need an else structure?

All i'm trying to do is allow the user to bring up a table when they search (as opposed to, say, just the standard form which comes up) - if they need it they check the box before clicking 'search'

Thanks guys

Eddie
 
Last edited:
Your code header doesn't specify an event for the code. Try using the On Click event...

Code:
Private Sub chkLaunchTableBox_Click()
    If Me!chkLaunchTableBox = True Then
        DoCmd.OpenQuery "qryMyQuery"
    End If
End Sub

Edit: Oops I need glasses. I copied & pasted the code, never caught the !
 
Last edited:
RichO said:
Code:
Private Sub chkLaunchTableBox_Click()
    If Me!chkLaunchTableBox = True Then
        DoCmd.OpenQuery "qryMyQuery"
    End If
End Sub


Code:
Private Sub chkLaunchTableBox_Click()
    If [b]Me.[/b]chkLaunchTableBox = True Then DoCmd.OpenQuery "qryMyQuery"
End Sub
 
Mile-O-Phile said:
Code:
Private Sub chkLaunchTableBox_Click()
    If [b]Me.[/b]chkLaunchTableBox = True Then DoCmd.OpenQuery "qryMyQuery"
End Sub
or

Private Sub chkLaunchTableBox_Click()
If Me.chkLaunchTableBox Then DoCmd.OpenQuery "qryMyQuery"
End Sub
 

Users who are viewing this thread

Back
Top Bottom