before update event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form . there are two fields "currency" and "payee". both i use combo
to show list of currency codes and list of payees.what i am trying to do is :
on the before update event of "payee" :-
Private Sub PAYEE_BeforeUpdate(Cancel As Integer)
If [CURRENCY] <> "GBP" Then
If [PAYEE] = "copmanyname" Then
MsgBox "Invalid Currency code/Payee"
Cancel = True
End If
End If
End Sub
(for this company i want it not to accept other than GBP)
i have code on the before update event of payee .but i dont know why it will
not promt.it is moving to the next field.but , if i use text field instead of
combo. the same code will work.any one can help me with this.
 
Move it to the After Update event. I would also change the code a little:

Private Sub PAYEE_BeforeUpdate(Cancel As Integer)
If Me![PAYEE] = "copmanyname" Then
If Me![CURRENCY] <> "GBP" Then
MsgBox "Invalid Currency code/Payee"
Cancel = True
End If
End If
End Sub
 
Klatuu said:
Move it to the After Update event. I would also change the code a
little:

Private Sub PAYEE_BeforeUpdate(Cancel As Integer)
If Me![PAYEE] = "copmanyname" Then
If Me![CURRENCY] <> "GBP" Then
MsgBox "Invalid Currency code/Payee"
Cancel = True
End If
End If
End Sub

AfterUpdate cannot be cancelled so moving the code to that event won't work.
 
Right, sorry about that.

Rick Brandt said:
Klatuu said:
Move it to the After Update event. I would also change the code a
little:

Private Sub PAYEE_BeforeUpdate(Cancel As Integer)
If Me![PAYEE] = "copmanyname" Then
If Me![CURRENCY] <> "GBP" Then
MsgBox "Invalid Currency code/Payee"
Cancel = True
End If
End If
End Sub

AfterUpdate cannot be cancelled so moving the code to that event won't work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top