Good morning all:
In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending line of code:
[CODE=vb]Me!txtLostDaysN oPaySeasonal = DSum("getNumber OfWeekdays([tblWC]![fldDateOfNoPayB egin], [tblWC]![fldDateReturned])", "qryTest", "[tblEmployees]![fldPayDistCode] = 'BK21312'")[/CODE]
In this, getNumberOfWeek days is a function that I define elsewhere in the module, as such:
[CODE=vb]Function getNumberOfWeek days(dteStartDa te As Date, dteEndDate As Date) As Integer
* * *
(A bunch of code to obtain number of weekdays between two dates because the 'w' option in DateDiff does not work)
* * *
End Function[/CODE]
But, when I run the application, it stops at the DSum line, saying "Run time error 3085: Undefined function 'getNumberOfWee kdays' in expression." As far as I can tell, DSum is supposed to be able to accept a user-defined function in that first argument. So it seems like Access isn't recognizing my function definition in the first place.
So, I imported all my stuff into a new database, and restarted the machine just in case corruption might be an issue, but I get the same result.
Weird, no?
In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending line of code:
[CODE=vb]Me!txtLostDaysN oPaySeasonal = DSum("getNumber OfWeekdays([tblWC]![fldDateOfNoPayB egin], [tblWC]![fldDateReturned])", "qryTest", "[tblEmployees]![fldPayDistCode] = 'BK21312'")[/CODE]
In this, getNumberOfWeek days is a function that I define elsewhere in the module, as such:
[CODE=vb]Function getNumberOfWeek days(dteStartDa te As Date, dteEndDate As Date) As Integer
* * *
(A bunch of code to obtain number of weekdays between two dates because the 'w' option in DateDiff does not work)
* * *
End Function[/CODE]
But, when I run the application, it stops at the DSum line, saying "Run time error 3085: Undefined function 'getNumberOfWee kdays' in expression." As far as I can tell, DSum is supposed to be able to accept a user-defined function in that first argument. So it seems like Access isn't recognizing my function definition in the first place.
So, I imported all my stuff into a new database, and restarted the machine just in case corruption might be an issue, but I get the same result.
Weird, no?
Comment