If Then tied to a button

rgreene

Registered User.
Local time
Today, 17:25
Joined
Jan 22, 2002
Messages
168
I have little to no programming ability so any advice (and details) is appreciated.

I have a field called PHLevel. And I want to click a button and based on the results in the PHLevel field open 1 of 3 forms (with just words on it).

So basically I want something like this


If PHLevel is < 7.2 Then
DoCmd.OpenForm (PHtoLow)

ElseIf PHLevel is >7.8 Then
DoCmd.OpenForm (PHtoHigh)

Elseif PHLevel is between 7.2 and 7.8 Then
DoCmd.OpenForm (HappyPH)

Is this possible if so what would I need to do.

Thanks,

Rick
 
Something like this should work,
Code:
Private Sub buttonName_Click()
    Select Case PHLevel 
        Case Is < 7.2 
            DoCmd.OpenForm "PHtoLow"
        Case Is > 7.8
            DoCmd.OpenForm "PHtoHigh"
        Case Else
            DoCmd.OpenForm "HappyPH"
    End Select
End Sub
 
Code:
Private Sub PHButton_Click()
 
    Select Case Me.PHLevel
        Case Is > 7.8
            DoCmd.OpenForm "PHTooHigh"
        Case Is < 7.2
            DoCmd.OpenForm "PHTooLow"
        Case Else
            DoCmd.OpenForm "HappyPH"
    End Select
 
End Function

Basically, Me.PHLevel tells the system to look in the control PHLevelField.

E:F!B :banghead:
 

Users who are viewing this thread

Back
Top Bottom