Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After update trigger 2

Status
Not open for further replies.

LordGarf

Programmer
Apr 13, 2005
34
BE
Hi all,

I have 2 tables. One called customer and one called order.

I created a form caled frmorder and when you open it you can add a new order. You will see an orderID and a customer ID wich is a locked textfield. Underneath the customerID I have 2 unliked textboxes with are called name and firstname. In the cusomerID text fields afterupdate I have the code
txtname = DLookup("name", "customer", "cusomerID=" & me.customerID)
txtfirstname = DLookup("firstname", "customer", "cusomerID=" & me.customerID)
So when customerID changes the fields below get automaticaly filled in with name and fistname.

Now next to the customer ID field I have a button witch opens a new form. Some kind of search form I created where you can search customers. When you close this form it will change customerID on the order form in the customer ID you selected on the search form.

I supposed the afterUpdate would be triggered so that the name and fistname would be refreshed to but this is not happening?? Howcome?

the code in the search form is easy and it fills in customer ID on frmOrder. but does not trigger any afterUpdate or change event.
private sub btnclose_Click()
Form_frmOrder.customerID.Value = [customerID]
DoCmd.Close acForm, Me.Name
end sub

Tanks in advance.

tank you,

best regards,
Lord_Garfield
 
If I remember correctly, the after update event is not triggered if you update the value in a field in the way you are suggesting, it is only after you 'manually' change the data in the field and then move the focus away from that field.

How about using the OnCurrent event? That way, when you close your Search form and open up your Order form it should display the correct informaiton for that current record based on the CustomerID being displayed.
 
AfterUpdate will not trigger on the field being updated by code. You could, however, call the AfterUpdate directly yourself, or put its code in a procedure of your own which you call both from the AfterUpdate event procedure as well as after closing the search form.
 
Tank you both of you..

It works now..

I created a new module with some modified version of the Dlookup and call it on the search form. And it works.

tank you,

best regards,
Lord_Garfield
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top