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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help With Mal-Functioning Function in a Query 1

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I have a select query in which the old version works fine, but in the new version I added a variable thru a function. The new version returns no data at all and the old version returns the correct two employees. Also, I don't think that the new version is picking up the defaults the way the old version did. Here is the old line of code that works:

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

Both are the WHERE clause, if it matters. Here is the new version, that does not work:

(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()))))

And the function the works with it is as follows:

Function GetNumWeeks()As Integer
GetNumWeeks=13
End Function

Can anyone see what is wrong with the new version? Very simply, the query is to bring up a pop-up window to enter the starting date, with a default of todays date minus 7 days, and then set the ending date to 13 weeks less than the starting daye. Thanks alot for any help rendered.
 
Maybe I should just ask a simplier question than the one above. How does Access, when run the query know to go to the module tab andselect the approperiate module? I guess I'm still in my old world, where we would call or list in the code other programs or modules. I just can't see how the query can find the correct module. Thanks.
 

I went back to the threads you've worked in and see that I made a mistake in this particular query. Here is the correction.


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

Sorry for the inconvenience. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
It works. Thank you again so very, very much, Terry. As usual the professor has the right answer. But still, if you have the time, please tell me how Access's query knows to look in the module tab and which module to use? This is just FMI. Thanks.
 

Modules are global to the application and therefore can be used throughout the database. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top