VBA for checking to see if fields in a form are not empty when 'close form' button is executed

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
299
My script only included Textboxes.

I thought you said my script worked perfectly but you wanted two textboxes exclude.
I asked what were the names of the Textboxes you wanted excluded and you said:

txtIncidentID
DTPicker1

Well

DTPicker1

Is not a Textbox.

My bad. I appoligize. Regardless, your code is working fine. I just changed this part from:

Code:
If x > 0 Then
to this:

Code:
If x > [B]1[/B] Then
And that seems to cancel out the 2 controls that autopopulate when the form is opened and doesnt trigger the yes/no prompt in your code when the close button is clicked. Perfect! THanks again, My Aswer Is This
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,743
Office Version
2013
Platform
Windows
Well if that works for you great.
I think you will find if one of the other Textboxs have a value in them other then the one you wanted excluded you will not get a warning message.

So for example if the textbox you wanted excluded is empty but TextBox4 has a value in it the script will not give you a warning.
If that proves true you will have to get back with me.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,096,444
Messages
5,450,485
Members
405,613
Latest member
Arpit

This Week's Hot Topics

Top