Results 1 to 7 of 7

Handle Run Time Error

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    143

    Handle Run Time Error

    Hi There,

    I have a VBA fill in form that works great however is for some reason someone was to type the date in wrong for example 12032018 without / or - I get a run time error.

    What I would like to do is just have a simple box come up to say "you have typed in something wrong please check all your entries and click the update button again."

    Is this possible?

    This is the VBA code I am using

    Private Sub CommandButton1_Click()
    row_number = 0
    Do
    DoEvents
    row_number = row_number + 1
    item_in_review = Sheets("Driver Data Input").Range("A" & row_number)
        If item_in_review = ComboBox1.Text Then
            TextBox1.Text = Sheets("Driver Data Input").Range("L" & row_number)
            TextBox2.Text = Sheets("Driver Data Input").Range("M" & row_number)
            TextBox3.Text = Sheets("Driver Data Input").Range("N" & row_number)
            TextBox4.Text = Sheets("Driver Data Input").Range("O" & row_number)
            TextBox5.Text = Sheets("Driver Data Input").Range("P" & row_number)
            TextBox6.Text = Sheets("Driver Data Input").Range("Q" & row_number)
            TextBox7.Text = Sheets("Driver Data Input").Range("R" & row_number)
            TextBox8.Text = Sheets("Driver Data Input").Range("S" & row_number)
            TextBox9.Text = Sheets("Driver Data Input").Range("T" & row_number)
            TextBox10.Text = Sheets("Driver Data Input").Range("U" & row_number)
            TextBox11.Text = Sheets("Driver Data Input").Range("AJ" & row_number)
            End If
            
            Loop Until item_in_review = ""
    End Sub
    
    Private Sub CommandButton2_Click()
    Unload Me
    End Sub
    
    Private Sub CommandButton3_Click()
    row_number = 0
    Do
    DoEvents
    row_number = row_number + 1
    item_in_review = Sheets("Driver Data Input").Range("A" & row_number)
        If item_in_review = ComboBox1.Text Then
            Sheets("Driver Data Input").Range("L" & row_number) = TextBox1.Text
            Sheets("Driver Data Input").Range("M" & row_number) = CDate(TextBox2.Text)
            Sheets("Driver Data Input").Range("N" & row_number) = TextBox3.Text
            Sheets("Driver Data Input").Range("O" & row_number) = TextBox4.Text
            Sheets("Driver Data Input").Range("P" & row_number) = CDate(TextBox5.Text)
            Sheets("Driver Data Input").Range("Q" & row_number) = CDate(TextBox6.Text)
            Sheets("Driver Data Input").Range("R" & row_number) = TextBox7.Text
            Sheets("Driver Data Input").Range("S" & row_number) = CDate(TextBox8.Text)
            Sheets("Driver Data Input").Range("T" & row_number) = TextBox9.Text
            Sheets("Driver Data Input").Range("U" & row_number) = CDate(TextBox10.Text)
            Sheets("Driver Data Input").Range("AJ" & row_number) = CDate(TextBox11.Text)
            
            End If
            
            Loop Until item_in_review = ""
    End Sub
    
    
    
    Private Sub UserForm_Click()
    
    End Sub
    Thanks
    Last edited by fastcar; 03-13-2018 at 03:35 PM. Reason: Solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is this a good way to handle error?
    By david90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2013, 08:08 PM
  2. odbcconnection error handle
    By jmendes65 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2013, 11:21 AM
  3. 1004 Error due to nasty server - unable to error handle
    By PuppyOnTheRadio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2013, 06:39 AM
  4. How to handle automation error?
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2006, 09:00 PM
  5. [SOLVED] Error Handle
    By PR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2005, 06:05 PM
  6. [SOLVED] How to handle error 8007000e Memory Error
    By L. A. M. in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-27-2005, 11:05 PM
  7. [SOLVED] Handle Error.
    By Cactus [ÏÉÈËÇò] in forum Excel General
    Replies: 2
    Last Post: 02-16-2005, 06:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1