OscarAlberto
Programmer
How do I go about providing the user with a MsgBox containing information about an error made while making data entries via an InputBox, and then returning to the execution point where it was left when the error appeared? If I provide a UserForm to obtain input it is relatively easy to trap an error using TextBox_Exit but I cannot figure how to do it with an InputBox. The main reason not to use UserForms is size of the app.
Following the code:
'Assigns values to variables to keep track of # of customers and Doctors categories.
Counter = 0
Counter2 = 0
Counter3 = 0
For Each r In Doctors
For Each t In Customers
Msg = InputBox("Enter the BASE TARIFF for" & _
Space(3) & r & _
vbCrLf & vbCrLf & "and Doctor = " & Space(3) & t, _
"SOFTWARE – Medical Services Application")
'Enters the name of each doctor in the database.
If Not IsNumeric(Msg) Or Msg <= 0 Then
Msg = MsgBox(vbTab & _
"TARIFF DATA" & _
vbCrLf & vbCrLf & vbCrLf & _
"The figure you entered for BASE TARIFFS is NOT VALID." & _
vbCrLf & vbCrLf & vbCrLf & _
"To continue, PRESS OK and launch the MEDICAL Data Menu again." & _
vbCrLf & vbCrLf & vbCrLf, _
vbOKOnly + vbCritical, _
"SOFTWARE – Medical Services Application")
'Clears data from collections.
For Counter = 1 To Tariffs.Count
Tariffs.Remove 1
Next
For Counter = 1 To Doctors.Count
Doctors.Remove 1
Next
For Counter = 1 To Customers.Count
Customers.Remove 1
Next
'Stops execution of code.
Exit Sub
Thanks in advance.
OscarAlberto.
Following the code:
'Assigns values to variables to keep track of # of customers and Doctors categories.
Counter = 0
Counter2 = 0
Counter3 = 0
For Each r In Doctors
For Each t In Customers
Msg = InputBox("Enter the BASE TARIFF for" & _
Space(3) & r & _
vbCrLf & vbCrLf & "and Doctor = " & Space(3) & t, _
"SOFTWARE – Medical Services Application")
'Enters the name of each doctor in the database.
If Not IsNumeric(Msg) Or Msg <= 0 Then
Msg = MsgBox(vbTab & _
"TARIFF DATA" & _
vbCrLf & vbCrLf & vbCrLf & _
"The figure you entered for BASE TARIFFS is NOT VALID." & _
vbCrLf & vbCrLf & vbCrLf & _
"To continue, PRESS OK and launch the MEDICAL Data Menu again." & _
vbCrLf & vbCrLf & vbCrLf, _
vbOKOnly + vbCritical, _
"SOFTWARE – Medical Services Application")
'Clears data from collections.
For Counter = 1 To Tariffs.Count
Tariffs.Remove 1
Next
For Counter = 1 To Doctors.Count
Doctors.Remove 1
Next
For Counter = 1 To Customers.Count
Customers.Remove 1
Next
'Stops execution of code.
Exit Sub
Thanks in advance.
OscarAlberto.