Userform Msg Box

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
583
I'm working with a User form that has eight option buttons and a text box. The user should only select one of the 8 option buttons after inserting text in the text box.

How can I get a message box to pop up if the user select an optionbutton and click OK before inserting text in the text box?

Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Fryer Tuck

Board Regular
Joined
Mar 20, 2002
Messages
64
Write a subroutine that is called by the first line of each button's routine. The subroutine would be something like:

Sub BtnCk()
If TextBox1 = Empty Then
put in your message box here
End if
End Sub

F.T.
 

parry

MrExcel MVP
Joined
Aug 20, 2002
Messages
3,355
Hi, Im only a beginner myself but I think you would first set focus to the text box when the form opened and then disable all the option buttons until text was entered into the textbox. You would have to apply this to the change (or afterupdate) event on the textbox as well in case user blanked out the textbox info after previouly typing something in.

example
Private Sub UserForm_Activate()
TextBox1.setfocus
option1.enabled = false
option2.enabled = false
end sub

Private Sub TextBox1_AfterUpdate()
if TextBox1.value = ""
msgbox "You must enter a value in the textbox"
option1.enabled = false
option2.enabled = false
else
option1.enabled = true
option2.enabled = true
end if
end sub

Private Sub TextBox1_Change()
if TextBox1.value = ""
msgbox "You must enter a value in the textbox"
option1.enabled = false
option2.enabled = false
else
option1.enabled = true
option2.enabled = true
end if
end sub




_________________
cheers
Parry
This message was edited by parry on 2002-10-07 21:40
This message was edited by parry on 2002-10-07 21:41
This message was edited by parry on 2002-10-07 22:58
 

Fryer Tuck

Board Regular
Joined
Mar 20, 2002
Messages
64
Parry has a method that will work, although you should probably use the visible property rather than the enabled property.

F.T.
 

Forum statistics

Threads
1,144,363
Messages
5,723,919
Members
422,527
Latest member
JayTheKaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top