Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Function Problem with a Error!!! 1

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I have a function, GetNumWeeks, in the Module section, which is very simple:

Function GetNumWeeks() As Integer
GetNumWeeks = 13
End Function

I am TRYING to use this in a Select Query, in one line of code in the WHERE clause:

(Att.DateWeekStarting Between Nz([Enter Start Date], DateAdd("ww",-1,-GetNumWeeks(), Date()))
And Dateadd("ww",[Enter the Period], Nz(GetNumWeeks(), DateAdd("ww",-1,-GetNumWeeks(), Date()))))

Very simply, this is suppose to allow me to enter a Starting date, with a default of one week ago, and automatically set the end date to 13 weeks eariler than the start date. The 13 weeks is a defult from the function. When I try and run the query I get a message that says: Wrong number of arguements used with fuction in query exzpression. I am just getting my feet wet with functions and I don't know them very well. Thanks you to anyone who lends a helping hand on this one.
 

You have an extra comma in the query, before the new function call. It actually occurs twice. Remove the comma.

(Att.DateWeekStarting Between Nz([Enter Start Date], DateAdd("ww",-1,-GetNumWeeks(), Date()))
And Dateadd("ww",[Enter the Period], Nz(GetNumWeeks(), DateAdd("ww",-1,-GetNumWeeks(), Date()))))

The error occurred because you passed 4 parameters to the Dateadd function when only 3 are expected. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Oh, I understand that one. I made the changes and now I get the following message: "Undefined function 'GetNumWeeks' in expresion." I do not understand that one at all. I even made the module the same name as the function, normally I would have probably name it modGetNumWeeks, but I did try that also and it did not work either. Thanks for the help.
 
I rename the module again and it is now run. Thanks again for all of the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top