vba if statements

mendesj1

Registered User.
Local time
Yesterday, 19:05
Joined
Nov 9, 2011
Messages
30
Guys if anyone could help me understand why i get stuck on the one record in the sub table and have to hit escape to go to the next line to enter the next record , i dont get any errors with the code but seems like it is stuck in the loop

Private Sub Form_AfterUpdate()

'check for delta conditions
If Me![H-INDEX] = 1 And Me![PRICE] > 0 And Me![PROCcheckbox] <> True And Me!Scheckbox = False Then


Me!Dcheckbox = True
Me!PROCcheckbox = 0
Me!Scheckbox = 0
Me!Gcheckbox = 0
Me!Zcheckbox = 0
MsgBox ("Delta ")

Exit Sub
'check for sigma change to delta
ElseIf Me!Scheckbox = True And Me![PRICE] > 0 Then
'check for date and fixation basis
If IsNull(Me!FixationBasisOrderDetails) = True Or IsNull(Me![DATE FIXED BY CUST]) = True Then
MsgBox ("Please Enter A Fixation Basis and a date fixed by customer")
Me!Scheckbox = True
Me.Undo
Me.PRICE = 0

'if all fields enter change into delta
ElseIf IsNull(Me![DATE FIXED BY CUST]) = False And IsNull(Me!FixationBasisOrderDetails) = False Then
Me!Dcheckbox = True
Me!PROCcheckbox = 0
Me!Scheckbox = 0
Me!Gcheckbox = 0
Me!Zcheckbox = 0
End If

Exit Sub

'sigma check
ElseIf Me![H-INDEX] = 1 And Me![PRICE] = 0 And Me![PROCcheckbox] <> True Then
Me!Scheckbox = True
Me!PROCcheckbox = 0
Me!Dcheckbox = 0
Me!Gcheckbox = 0
Me!Zcheckbox = 0
MsgBox ("Sigma ")

Exit Sub
'gamma check
ElseIf Me![H-INDEX] = 0 And Me![PRICE] > 0 And Me![PROCcheckbox] <> True Then
Me!Gcheckbox = True
Me!PROCcheckbox = 0
Me!Dcheckbox = 0
Me!Scheckbox = 0
Me!Zcheckbox = 0
MsgBox ("Gamma ")


Exit Sub
'zeta check
ElseIf Me![H-INDEX] = 0 And Me![PRICE] = 0 And Me![PROCcheckbox] <> True Then
Me!Zcheckbox = True
Me!PROCcheckbox = 0
Me!Dcheckbox = 0
Me!Scheckbox = 0
Me!Gcheckbox = 0
MsgBox ("Zeta ")


Exit Sub

'fixed on fixed sales
Else
Me!PROCcheckbox = True
Me!Dcheckbox = 0
Me!Scheckbox = 0
Me!Gcheckbox = 0
Me!Zcheckbox = 0
MsgBox ("Sold at fixed Price with Fixed Price Coffee ")

Exit Sub
End If


End Sub
 
You are changing data on the form in the form's AFTER UPDATE event. So you basically have this:

Change data and save
After Update Fires and changes data
After Update Fires again because data was changed again
After Update Fires again because data was changed again
After Update Fires again because data was changed again
After Update Fires again because data was changed again
After Update Fires again because data was changed again
After Update Fires again because data was changed again

Get the picture? Use the BEFORE Update event, not After Update event.
 
bob thanks so much , work great thanks again for explaining it to me !!!
 

Users who are viewing this thread

Back
Top Bottom