I have a form with a CheckMark, Number field, and Text field. If the Check is true, there should not be any values in the Number or Text fields. If the Checkmark is False, there has to a number and text. The text is what is giving me problems. I have my Row Source Type as "Value List", and my Row Source, to be
""; "Hours"; "Trips"
My code is:
Private Sub NEXT_Click()
'If ([CKNoObs] = No) Then
' MsgBox "CkNoObs is No."
'End If
'If ([HorT] <> "Hours") Then
' MsgBox "H or T equals something besides hours"
'End If
'If ([HorT] <> "Trips") Then
' MsgBox "H or T equals something besides Trips"
'End If
If (([CKNoObs] = No) And ([HorT] <> "Hours")) Then
MsgBox "Please select Hours or Trips before proceeding.", vbOKOnly
[HorT].SetFocus
If (([CKNoObs] = No) And ([HorT] <> "Trips")) Then
MsgBox "Please select Hours or Trips before proceeding.", vbOKOnly
[HorT].SetFocus
Else
MsgBox "Should go to next form"
DoCmd.GoToRecord acDataForm, "FRM-EOM-ObHrsTrps", acNext
End If
End If
End Sub
The 'Code is where I was trying to find out where it was not working. It answered correctly if Checkbox was false. When I put "Hours" in, it gave me both the hours and trips message. So, it does not recognize Hours and Hours. Sorry my terminology is so bad.
Can you tell from my code what is not correct? Thanks, JL
""; "Hours"; "Trips"
My code is:
Private Sub NEXT_Click()
'If ([CKNoObs] = No) Then
' MsgBox "CkNoObs is No."
'End If
'If ([HorT] <> "Hours") Then
' MsgBox "H or T equals something besides hours"
'End If
'If ([HorT] <> "Trips") Then
' MsgBox "H or T equals something besides Trips"
'End If
If (([CKNoObs] = No) And ([HorT] <> "Hours")) Then
MsgBox "Please select Hours or Trips before proceeding.", vbOKOnly
[HorT].SetFocus
If (([CKNoObs] = No) And ([HorT] <> "Trips")) Then
MsgBox "Please select Hours or Trips before proceeding.", vbOKOnly
[HorT].SetFocus
Else
MsgBox "Should go to next form"
DoCmd.GoToRecord acDataForm, "FRM-EOM-ObHrsTrps", acNext
End If
End If
End Sub
The 'Code is where I was trying to find out where it was not working. It answered correctly if Checkbox was false. When I put "Hours" in, it gave me both the hours and trips message. So, it does not recognize Hours and Hours. Sorry my terminology is so bad.
Can you tell from my code what is not correct? Thanks, JL