Option buttons and IF expressions

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
 
A

Al Campagna

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."
 
A

Allen Browne

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
 
B

bmac

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
 
A

Al Campagna

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."
 

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

Top