How Do I filter Dsum results for a calculated control

T

tgh

Hi,

I've Got a form that gathers the order items details of an order grouped
under the order number [ORDNO].

I want to take the extended cost of all items in an order and have that
entered into the GR_COST bound control (to ORDER HEADERS tbl). This occurs on
the click event of my calculate button. Below is my sub function.
I get no errors, but it either calculates the entire CEXT field in the table
Order Details, or it returns 0.00 (which means it was getting null).
Variable strOrNo gets it's value from an unbound control on the form that
holds the current order number.
If I put the actual order number into the Dsum function, it works, but I
need it to insert the correct order number dynamically.

Private Sub cmdCal_Click()
'Get a Value for GR_COST

Dim dblGCost As Double
Dim strOrNo As String
strOrNo = Me.txtCurON.Value
dblGCost = Nz(DSum("[CEXT]", "Order Details", "[ORDNO] = 'strOrNo'"))

Me.GR_COST.Value = dblGCost
End Sub

Thanks
tgh
 

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

Top