How to require text box only if radio (option) selected.

R

Rob Lake

Wonder if anyone can tell me how to require a text box be completed only if a related radio (option) button is selected by the user first? Thanks in advance.
 
R

Randy Birch

Do you mean like this? ...

Private Sub Command1_Click()

If Option1.Value = True Then

If Len(Text1.Text) = 0 Then

MsgBox "Hey goof ... hand over the info"

Else

MsgBox "The textbox " & IIf(Len(Text1.Text), "contains", "does not
contain") & " data"


End If

Else

MsgBox "Option not selected - user not forced to enter data." & vbCrLf
& _
"The textbox " & IIf(Len(Text1.Text), "contains", "does not
contain") & " data"

End If

End Sub




--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


: Wonder if anyone can tell me how to require a text box be completed only
if a related radio (option) button is selected by the user first? Thanks in
advance.
 
R

Randy Birch

oops ... ignore if inapplicable ... I thought I was responding to a visual
basic question in the vb newsgroups.

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


: Do you mean like this? ...
:
: Private Sub Command1_Click()
:
: If Option1.Value = True Then
:
: If Len(Text1.Text) = 0 Then
:
: MsgBox "Hey goof ... hand over the info"
:
: Else
:
: MsgBox "The textbox " & IIf(Len(Text1.Text), "contains", "does not
: contain") & " data"
:
:
: End If
:
: Else
:
: MsgBox "Option not selected - user not forced to enter data." &
vbCrLf
: & _
: "The textbox " & IIf(Len(Text1.Text), "contains", "does not
: contain") & " data"
:
: End If
:
: End Sub
:
:
:
:
: --
:
: Randy Birch
: MVP Visual Basic
: http://vbnet.mvps.org/
: Please respond only to the newsgroups so all can benefit.
:
:
: : : Wonder if anyone can tell me how to require a text box be completed only
: if a related radio (option) button is selected by the user first? Thanks
in
: advance.
:
:
 

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