Option buttons and IF expressions

  • Thread starter Thread starter bmac
  • Start date Start date
B

bmac

I have a Form whereby I have set up a Frame (Frameq16) with 6 options in it.
Option # 5 = "Other". I have also created a TEXT box to have the user enter
their own description.

What I need to do is create some code that when "Option 5 Other", was chosen
and then removed, the descritpion TEXT box should also be set to null

This is my code

Private Sub Frameq16_AfterUpdate()
If Frameq16 = 5 Then
MsgBox "Please enter Other description"
Me!Frameq16.SetFocus
Me!q17.SetFocus
End If

End Sub
 
bmac,
Try...

Private Sub Frameq16_AfterUpdate()
If Frameq16 = 5 Then
MsgBox "Please enter Other description"
Me.q17.SetFocus
Else
Me.q17 = Null
Me.q18.SetFocus 'bypass q17
End If
End Sub

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Private Sub Frameq16_AfterUpdate()
If Frameq16 = 5 Then
MsgBox "Please enter Other description"
ElseIf Not IsNull(Me.q17) Then
Me.q17 = Null
End If
End Sub
 
hello - This seems to be working for me now... but I would really
appreciate any feedback if this is the best way to do it.

thanks


Private Sub Frameq16_AfterUpdate()
If Frameq16 = 5 Then
MsgBox "Please enter Other description"
Me!q16Other.SetFocus
End If

If Frameq16 = 1 Or 2 Or 3 Or 4 Or 6 Or 7 Then
q16Other = Null
Me!Frameq16.SetFocus
End If
End Sub
 
bmac,
The the logic of your scenario is Boolean... if it's a 5... do
something, anything ELSE do something different."

Private Sub Frameq16_AfterUpdate()
If Frameq16 = 5 Then
MsgBox "Please enter Other description"
Me!q16Other.SetFocus
Else
q16Other = Null
Me!FieldAfter_q16Other.SetFocus
End If
End Sub

You don't have to interrogate Frameq16 for values 1,2,3,4,6,or 7.
"Not a 5" covers that.

And, if the user selects anything other than a 5, you should null out
q16 (as you do), but... then you should send them to the next field after
q16Other. By selecting something other than 5, the user... in effect...
indicates that q16Other is not needed... so let's move on.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Back
Top