Two AfterUpdate Events Needed

Stephanie T.

Registered User.
Local time
Today, 00:53
Joined
Jun 20, 2002
Messages
60
Does anyone know, can I have two AfterUpdate events happen from the same field?

I have a “Distributor” field which is a combo box. This box triggers a cascading combo box effect so that once the Distributor is chosen, the “Warehouse” field, also a combo box, only allows for the choices associated with that Distributor.

I would also like to have two fields, the “Spoilage” and the “Freight” to automatically fill based on the information for that Distributor. So, at the moment, I would assume that this would be an AfterUpdate, once I choose the Distributor then everything would fill in. Or, is there another event that would work as easily as AfterUpdate, that wouldn’t conflict with the cascading combo box coding already in place?

I'm on Access 97.

Thank you for your help!
Stephanie
 
Hi Stephanie

Can you simply write code to populate the spoilage and freight fields, to execute as part of the AfterUpdate event on the Distributor field?

It could be in the same subroutine, and just happen after the code for the Warehouse combo box, or as a stand alone sub that is called by the AfterUpdate event on the Distributor field.

Does this help?

Dan

:)
 
Dan,

Now I have a bigger problem with all of this. Not only can I not seem to get the two events to happen when put together, but now, I can’t seem to get the auto fill code that was working to work. Any thoughts?

Here is the autofill code for filling the Spoilage and the Freight fields (yes it’s called Freight in this form and FreightAllowance in the tblDistributors).

Private Sub cboDistributor_AfterUpdate()
On Error GoTo Err_cboDistributor_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "cboDistributor = '" & Me!cboDistributor & "'"

' Look up Distributor's Spoilage and assign it to Spoilage control.
Me!Spoilage = DLookup("Spoilage", "tblDistributors", strFilter)
Me!FreightAllowance = DLookup("Freight", "tblDistributors", strFilter)

Exit_cboDistributor_AfterUpdate:
Exit Sub

Err_cboDistributor_AfterUpdate:
MsgBox Err.Description
Resume Exit_cboDistributor_AfterUpdate

End Sub

So now this won’t work. I’ve tested it a few times now, and compared it to other similar code and I’m stumped. It used to work. Once I get this working, I’ll try to incorporate it into the code for the Cascading Combo Boxes and see if I can use your suggestion of simply having both in the After_Update.

Any help would be greatly appreciated.

Best to you,
Stephanie :confused:
 

Users who are viewing this thread

Back
Top Bottom