OK Tom, Now I'm Lost. Could you show me? Also how do I set the table and
form varaibles when I call this function from the form?
Thanks
DS
Like This? Still trying to set variables though.
Public Function NOEX(CDQuantity As Integer, CDPrice As Currency, CDCheckID
As Integer, _
CDDiscountDP As Integer, strForm As Form, strTable As TableDef) As
Currency
NOEX = Round(Nz(DSum("(CDQuantity*CDPrice)", "strTable", "CDCheckID = "
& Forms!strForm!TxtCheckID & " AND CDDiscountDP = 0"), 0), 2)
End Function
Thanks
DS
Tom van Stiphout - 22 May 2008 14:39 GMT
You're warm, but a form object is not a string.
function f(frm as form, tbl as dao.tabledef)
x = DSum("SomeField", tbl.Name, "Somefield=" & frm!SomeControl.Value)
Call this from for example a button_click event:
x = f(Me, Currentdb.Tabledefs("SomeTable"))
Of course this would imply that you can call f only with forms that
have SomeControl as a control name. If the control name varies, pass
in a control object rather than a form object.
-Tom.
>Like This? Still trying to set variables though.
>
[quoted text clipped - 8 lines]
>Thanks
>DS
DS - 22 May 2008 16:28 GMT
Thanks, Lifes getting better. The control name is always the same, it's only
the form and the table that changes. This works though.
The Function
Public Function BIG (frm as form, tbl as dao.tabledef)
BIG = DSum("Price", tbl.Name, "PriceID=" & frm!SomeControl.Value)
End Fuction
Calling it from the On Click of a list box.
Me.Text0 =BIG(Me, Currentdb.Tabledefs("tblPrices"))
Once again,
Thank You
DS