Trying First Function Not working!

Kassy

Registered User.
Local time
Today, 11:23
Joined
Jan 25, 2006
Messages
66
I am trying to use an example to write my first function. Iv'e copied it from an old version of Access/VB (Access 97). Function FirstOfNextMonth().
I create a new module, type this in and assign the results of the calculation = DateSerial(Year(Now), Month(Now) +1,1. End Function. I try to comile it but the only option is to compile whole Database. No error message ocurs, so I save it as FirstOfNextMonth(). I try to add it to a form for adding members to my database by using a text box and seet the control to this function but when I view my form I get #Name error. What am I doing wrong? I'm using Access 2000.
 
Don't name the module the same as the function!
 
Thanks It does work, shame they dont explain that in the example. In fact it shows the module being saved as the same name as the fuction or at least it shows the same name in the control of the text box I am trying to use the function in so I assumed that was the module name. Any chance you'd know how to alter the function to show a beginning date 1 year in advance every year using the first of September (of any Year) without having to use a parameter to ask for a start date. My Query uses this:-
[DateFieldName] Between IIf(Format(Date(),"mmdd")>"0801", DateSerial(Year(Date()),9,1), DateSerial(Year(Date())-1,9,1)) And Date();
I would like to turn it into a function to use on member forms and reports to show the date as a 'Season'. Dont know if Im making any sense?
 
Have you brought up the VBA help on DateSerial? It will do what you need.
 

Users who are viewing this thread

Back
Top Bottom