IF/Then/Else Statements

G

Guest

I am trying to use the results of 2 check boxes on an underlying form, when I
select a command box to select the correct macro to use the code I have
created is as follows:private Sub CmdPayUpdate_Click()
On Error GoTo Err_CmdPayUpdate_Click

Dim stDocName As String
Dim stDocNames As String
Dim stDocNames2 As String

stDocName = "Pay Calculation 2007"
stDocNames = "Pay Calculation 2006 union"
stDocNames2 = "Union Non Skills"

If Me.AAAP_Enrolled = "No" Then
DoCmd.RunMacro stDocName2
Else
If Me.Union_Member = "Yes" Then
DoCmd.RunMacro stDocNames
Else
DoCmd.RunMacro stDocName
End If
End If

Exit_CmdPayUpdate_Click:
Exit Sub

Err_CmdPayUpdate_Click:
MsgBox Err.Description
Resume Exit_CmdPayUpdate_Click

End Sub

however it doesn't seem to work, can anyone help
 
G

Guest

David,

Checkboxes return booleans, ie. True/False. You're evaluating them against a
string value. Try:
If Me.AAAP_Enrolled = False Then

which can be shortened to:
If Not Me.AAAP_Enrolled Then

and

If Me.Union_Member = True Then

which can be shortened to:

If Me.Union_Member Then

HTH,
Barry
 

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

Similar Threads


Top