G
Guest
Hi,
I'm stuck and need some help desperatly.
what I'm trying to do is to create a universal function (stored in a module).
Inside the funtion i use the built-in function dsum to calculate something.
The dsum function needs a field, table and criteria. Im trying to pass these
criteria whem I'm calling my own function.
for example I call my function with:
MyFunction TxtTotal, "[planned].[MyNumber]", "planned","WHERE
[planned].[weeknumber] = format(date(),'ww')"
My function then looks like:
Public Function MyFunction(MyOutput As TextBox, MyField As String, MyTable
As String, MyCriteria As String)
MyOutput = dsum(MyField, MyTable, MyCriteria)
msgbox Error 'just to check'
End Function
What am I doing wrong because I keep getting errormessage
Syntax error (missing operator) in query expression: 'WHERE
[planned].[weeknumber] = format(date(),'ww')'
I've tried placing semi-collons and collons everywhere (thinking that's the
problem) but nothing helps. I even tried datepart() instead of format() in my
criteria.
How do I pass on my variables to my function so that the built-in function
dsum() works?
Please help me!!!
BTW if I run an sql statement (like I use now as rowsource for a listbox):
"SELECT * from [planned] WHERE [planned].[weeknumber]= format(date(),'ww')"
it works perfectly!
Thanx!
Pain
I'm stuck and need some help desperatly.
what I'm trying to do is to create a universal function (stored in a module).
Inside the funtion i use the built-in function dsum to calculate something.
The dsum function needs a field, table and criteria. Im trying to pass these
criteria whem I'm calling my own function.
for example I call my function with:
MyFunction TxtTotal, "[planned].[MyNumber]", "planned","WHERE
[planned].[weeknumber] = format(date(),'ww')"
My function then looks like:
Public Function MyFunction(MyOutput As TextBox, MyField As String, MyTable
As String, MyCriteria As String)
MyOutput = dsum(MyField, MyTable, MyCriteria)
msgbox Error 'just to check'
End Function
What am I doing wrong because I keep getting errormessage
Syntax error (missing operator) in query expression: 'WHERE
[planned].[weeknumber] = format(date(),'ww')'
I've tried placing semi-collons and collons everywhere (thinking that's the
problem) but nothing helps. I even tried datepart() instead of format() in my
criteria.
How do I pass on my variables to my function so that the built-in function
dsum() works?
Please help me!!!
BTW if I run an sql statement (like I use now as rowsource for a listbox):
"SELECT * from [planned] WHERE [planned].[weeknumber]= format(date(),'ww')"
it works perfectly!
Thanx!
Pain