Halting Program

Jazzmann

New Member
Joined
Aug 10, 2009
Messages
16
I need a way to halt the program until the user enters info into a textbox on a user form

'Check if Date Entered is Empty
If Me.txtDateEnt.Value = "" Then
MsgBox "Date Entered is Missing", vbExclamation, "Date format error"
Me.txtDateEnt.SetFocus
Exit Sub
End If

This code keeps going after the msgbox button is clicked with giving the user the opportunity to enter the information.

TIA
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Private Sub cmdAdd_Click()

'check for duplicate estimate number entry's
If WorksheetFunction.CountIf(ActiveSheet.Range("D10:D609"), Me.txtEstNum.Value) > 0 Then
MsgBox "This estimate number already exists"
Exit Sub
End If
'Add the data to the database
Set ws = Sheet1
Set LRow = Sheet1.Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
'lRow.Select
With ws
LRow.Value = Me.txtPropNam.Value
LRow.Offset(0, 1).Value = Me.txtPropAdd.Value
LRow.Offset(0, 3).Value = Me.cboClass.Value
LRow.Offset(0, 4).Value = Me.cboEstr.Value
LRow.Offset(0, 5).Value = Me.txtJobDesc.Value
LRow.Offset(0, 6).Value = Format(Me.txtDateEnt.Value, "mm/dd/yyyy")
LRow.Offset(0, 11).Value = Me.cboStaus.Value
End With
'Check if Date Entered is Empty
If Me.txtDateEnt.Value = "" Then
MsgBox "Date Entered is Missing", vbExclamation, "Date format error"
Me.txtDateEnt.SetFocus
Exit Sub
End If
Unload Me
End Sub
 
Upvote 0
You should have the script check all these controls at the beginning of the script to see if they are empty.
I do not believe its possible to stop a script mid way and wait for a user to enter a value before script continues.

You have this:

LRow.Offset(0, 6).Value = Format(Me.txtDateEnt.Value, "mm/dd/yyyy")

Before you even check to see if
Me.txtDateEnt.Value = ""

The only way to stop a script to load a value into a control would be to have a Inputbox Popup

Put the value into the Inputbox then load this value into the control.
 
Upvote 0
Thank you for your response and time. The reason its after the input is, the user has a choice to leave some of the controls blank during the add click and return to edit later. The only one that cannot be blank is the "Date Entered". It's part of an auto ID number calculation. I will use the inputbox instead of the msgbox.

Thanks again
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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
Back
Top