Userform validation rule wont work - Please help

mcwillis81

New Member
Joined
Dec 3, 2015
Messages
30
[FONT=&quot]Hi all,[/FONT]

[FONT=&quot]First time posting here about access so any help will be greatly appreciated.[/FONT]

[FONT=&quot]I'm creating a user-form in access and due to the remit given to me i,m trying to avoid as little code as possible so therefore i'm trying to set some validation for a text box.[/FONT]

[FONT=&quot]it shouldn't be that difficult but i'm getting nowhere![/FONT]

[FONT=&quot]It should go like this;[/FONT]

[FONT=&quot]if combobox value = x and textbox is null 'then trigger the validation[/FONT]

[FONT=&quot]I've tried a couple different variations of;[/FONT]

(([Combo_Select_P]="Project1") And ([TXT_Str_Date] Is Null))

nothing seems to be working - please help
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi, if you want to avoid code it would be simplest to put the validation in the table, which requires no no code at all.

For a "null" check in a form control I would generally always use an "is null or blank" check as the safest, since null is a little hard to work with and can be confusing if a textbox holds an empty string ("") but is still not null.

Therefore,
(([Combo_Select_P]="Project1") And (Nz([TXT_Str_Date],"") = ""))

In the above expression I assume TXT_Str_Date holds strings (specifically, dates stored as strings). Not sure how you are using this code. You could have a valid expression but not be using it correctly.
 
Upvote 0
Thanks Xenou this has sorted it.

I can't add validation to the table as the userform changes recordsource depending on user combobox selection (I have lots of tables to interact with).

(Just bad naming of TXT_str_date should be more like Textbox_Start_Date.

However this did the trick! Thank you !!!!!!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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
Back
Top