1st Day Of The Month

GregSmith

Registered User.
Local time
Today, 14:59
Joined
Feb 22, 2002
Messages
126
I have a form that uses the =date() to get todays date. I need it to pop up a message if the day is the 1st of each month.

Any clues?
 
To find the first day of current month the code is

DateSerial(Year(Date), Month(Date), 1)

If you assign your date() to a variable x
and the above to a variable y all you need to do is pop up a message if x = y

HTH
Col
 
Heck, just use If(Day(Date()) = 1 Then...
 
David R - that works great but my main problem is that when you add a new record and it goes to the new screen and updates the record # and the date field automatically. How can I get it to test the day right after it inputs the date for you? Right now, I have to grab focus of the field for it to tell me that it's the first of the month...
 
Try the Form's Current event instead of the Click event.
 
Where is the Current event located? I only see where you can put events that require some type of action from the user...
 
You're probably using the event associated with an individual field on your form. It took me a while to find the way to get to Form-level events too; click the small grey box in the top left of your form in design view twice, you should get the form's properties. Go to Events and find Current, then click the [...] to get into the event.
Current runs whenever a different record is made the 'current' one, including when the form is opened. That makes it a good place for keeping track of unbound calculations on a form.
 
I am clicking on it but it closes the form out of design mode...
 
Top left hand corner of the form in design mode. It's the little grey square with a black square in it. Right click.
 
Hmmm, I'm not talking about the Form View/Design View button. When I open a form in design view I get a ruler across the top, and to the left of that a small grey box. Double-click on that and you'll get the Form's Properties.

Alternatively, go up to the taskbar where it has a white dropdown box and pick 'Form' from the list, then click the Properties button to view Properties.

HTH,
David R
 
One more question...

If the day=1 it pops up my message telling me it's the end of the month and now I would like to have it fill in 3 fields that are combo boxes. Any idea??
 
Not quite sure what you're asking. Are these combo boxes filled in from other values, or are you wanting the user to input new values into them to store in your table on this date?
You can do just about anything from the code event after the If...Then statement. SetFocus will allow you to place the cursor on a specific combo box. OpenForm will let you open a separate form to fill in blanks there. This is probably worth a new topic since you've solved your original problem, plus we may need more detail on what you are trying to accomplish.
 

Users who are viewing this thread

Back
Top Bottom