View Full Version : Dsum AfterUpdate Event


dazz2302
07-22-2010, 09:32 PM
Hi folks,

Could someone see where I am going wrong with this AfterUpdate event that I have on a form named INVOICELOG:

What i am trying to do is an after Update event that is assigned to a combo box field. When a combo box selection is made, a running total in the [CONTRACTAMTEXCGST] field (data type currency) is then populated.

In other words:

SELECT: DSum [CONTRACTAMTEXCGST] (Currency field)
FROM: [CONTRACTS] table
WHERE: Combo box selection named [CRCREFERENCE] = CRCREFERENCE field in the [CONTRACTS] table.

The following code was entered in under CRCREFERENCE property events.

Private Sub CRCREFERENCE_AfterUpdate()
CONTRACTAMTEXCGST = DSum("[CONTRACTAMTEXCGST]", "[CONTRACTS]", "[CRCREFERENCE]='" + cboCRCREFERENCE + "' ")
End Sub

The result is a blank field against CONTRACTAMTEXCGST when a selection is made in the CRCREFERENCE combo box.

A relationship exists against the two tables.

As a newbie, i know this is code is wrong in my attempt but any help in identifying a possible solution would be greatly appreicated.
Many Thanks
Dazz

Galaxiom
07-22-2010, 11:06 PM
Haven't looked at what you are actually trying to achieve but try this code:


Me!CONTRACTAMTEXCGST = DSum("[CONTRACTAMTEXCGST]", "[CONTRACTS]", "[CRCREFERENCE]='" & Me!cboCRCREFERENCE & "'")

dazz2302
07-24-2010, 03:50 AM
Thanks Galaxiom.
I will give the code a go.
I appreciate your help and for responding.
Kind regards
Dazz