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

kbishop94

Board Regular
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
 

My Aswer Is This

Well-known Member
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:

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top