Stop Form from loading on error

mond007

New Member
Joined
Oct 9, 2008
Messages
34
Hi

I am trying to chaneg form processing. The application has a screen and loads data file etc... but owing to data integritty problems I have found that in some cases it DEBUGs this is because it find either an invalid date etc.

How can I halt loading the form ?

I have tried 'Unload Me' but this still loads the form regardless after the Msgbox.

The following is a short version of the code.

Code:
Private Sub UserForm_Initialize()
    
On Error GoTo error_hander_loading
    If gl_mode = "Add" Then
        mode_label.Caption = "Add"
        cmdb_action.Caption = "Add Intervention"
    End If
    If gl_mode = "Modify" Then
        
        'Load Existing Record Details
        gl_error_line = "Loading Case Number " & load_intervention_row_no
        
        mode_label.Caption = "Modify"
        cmdb_action.Caption = "Save Intervention"
        Set Db_WS = Worksheets("Tracker")
        Db_WS.Activate
        
        'LOAD EXISTING DATA IN COLUMNS
        cbox_new_continuation = Db_WS.Cells(load_intervention_row_no, [col_new_continuation].Column)
        txtb_firstname = Db_WS.Cells(load_intervention_row_no, [col_firstname].Column)
    End If
Exit Sub
error_hander_loading:
        MsgBox "An error has occurred fix the Data and re-try"
        Resume Next
        Unload Me
End Sub

Thanks in Advance.
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Watch MrExcel Video

Forum statistics

Threads
1,127,758
Messages
5,626,691
Members
416,200
Latest member
Pulsar3000

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
Top