Stopping VBA Code Running if control is true

michaeljryan78

Registered User.
Local time
Today, 18:17
Joined
Feb 2, 2011
Messages
165
I have a buch of code in the BeforeUpdate event of a form that I want NOT to run if a control is true [precrg] = true. I know this should be very simple, but the answer eludes me. Please help! code is below:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(CounselID) = False And CounselID <> "" Then
If IsNull(STATUS) = True Or STATUS = "" Then
STATUS.SetFocus
STATUS.BackColor = vbYellow
MsgBox "THE INFORMATION ON THIS FORM HAS CHANGED, UPDATE THE REQUEST STATUS", vbCritical
Exit Sub
Else: STATUS.SetFocus
STATUS.BackColor = vbWhite
End If
End If
If IsNull(INorOUT) = False And INorOUT <> "" Then
If IsNull(Strategy) = True Or Strategy = "" Then
Strategy.SetFocus
Strategy.BackColor = vbYellow
MsgBox "You must enter a value in strategy", vbCritical
Exit Sub
Else: Strategy.SetFocus
Strategy.BackColor = vbWhite
End If
End If
If INorOUT = "Outside" Then
If IsNull(NOT_IN_HOUSE) = True Or NOT_IN_HOUSE = "" Then
NOT_IN_HOUSE.SetFocus
NOT_IN_HOUSE.BackColor = vbYellow
MsgBox "You must enter a value in NOT_IN_HOUSE", vbCritical
Exit Sub
Else: NOT_IN_HOUSE.SetFocus
NOT_IN_HOUSE.BackColor = vbWhite
End If
End If
If INorOUT = "Outside" Then
If IsNull(REASON_NOT_IN_HOUSE) = True Or REASON_NOT_IN_HOUSE = "" Then
REASON_NOT_IN_HOUSE.SetFocus
REASON_NOT_IN_HOUSE.BackColor = vbYellow
MsgBox "You must enter a value in REASON_NOT_IN_HOUSE", vbCritical
Exit Sub
Else: REASON_NOT_IN_HOUSE.SetFocus
REASON_NOT_IN_HOUSE.BackColor = vbWhite
End If
End If
If INorOUT = "Outside" Then
If IsNull(Budgeter) = True Or Budgeter = "" Then
Budgeter.SetFocus
Budgeter.BackColor = vbYellow
MsgBox "You must enter a value in Budgeter", vbCritical
Exit Sub
Else: Budgeter.SetFocus
Budgeter.BackColor = vbWhite
End If
End If
If IsNull(Budget) = False And Budget <> "" Then
If IsNull(BudgetAppDate) = True Or BudgetAppDate = "" Then
BudgetAppDate.SetFocus
BudgetAppDate.BackColor = vbYellow
MsgBox "You must enter a value in BudgetAppDate", vbCritical
Exit Sub
Else: BudgetAppDate.SetFocus
BudgetAppDate.BackColor = vbWhite
End If
End If

End Sub

thanks!:confused:
 
At the beginning of the sub:

Code:
If precrg = true then
    Exit sub
End if
 

Users who are viewing this thread

Back
Top Bottom