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,762
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,102,646
Messages
5,488,079
Members
407,624
Latest member
NatashaGillWH

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top