UserForm make option button and textboxes mandatory

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Okay. So i have created a userform with several textboxes and optionbuttons.

What i have achieved until now is that ceartain textboxes are mandatory and have to be filled. But i dont seem to get it with the optionbuttons and i dont know why.

the if statement is as follows:

VBA Code:
If Me.ADA.Value <> "" And Me.datummat.Value <> "" And Me.KommNr.Value <> "" And Me.Empfänger.Value <> "" And Me.Artikel.Value <> "" And (Me.Ausgabe.Value = "wahr" Or Me.Rücknahme.Value = "wahr") Then

now you may think that the statement
VBA Code:
Me.Ausgabe.Value = "wahr"
could be the error. But i have tried the whole if statement without the textboxes and it worked as i wanted it to work, so it shouldnt be the error, right?

i dont know how i solve this problem. I need help.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
18,233
Office Version
  1. 2013
Platform
  1. Windows
On a Userform typically only one Option Button can be selected.
Unless you have them in Frames.
 

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
On a Userform typically only one Option Button can be selected.
Unless you have them in Frames.
i mean yes, but i want to kinda "force" the user to select an option button.

kinda like
"do not accept if no optionbutton is selected"

do you get what i mean?
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
7,054
Office Version
  1. 2019
Platform
  1. Windows
i mean yes, but i want to kinda "force" the user to select an option button.

kinda like
"do not accept if no optionbutton is selected"

Try adding line like following & see if does what you want

VBA Code:
'both optionbuttons False
If Not Me.Ausgabe.Value And Not Me.Rücknahme.Value Then MsgBox "Selection Required": Exit Sub

Dave
 

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Try adding line like following & see if does what you want

VBA Code:
'both optionbuttons False
If Not Me.Ausgabe.Value And Not Me.Rücknahme.Value Then MsgBox "Selection Required": Exit Sub

Dave
sadly this did not work.

also i need it in ADDITION to textboxes, which have to be filled.
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
7,054
Office Version
  1. 2019
Platform
  1. Windows
sadly this did not work.

also i need it in ADDITION to textboxes, which have to be filled.

Not sure why - if both OptionButtons are False should display the msgbox & exit sub

Helpful if you can post all the code for forum to give better idea of what you are doing.

Dave
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,484
Messages
5,770,364
Members
425,612
Latest member
martinijr

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