Using one form which creates todays date, another form for TOMORROWS date

bo8482

Registered User.
Local time
Today, 02:37
Joined
Feb 17, 2009
Messages
50
Hi

I have a basic data entry form whereby users enter the details of people who need to be paid. It then populates a table, and the date is set to todays date automatically.

However, some people require payment the next day, so I would like my users to open up another form which populates the table with tomorrows date automatically.

Then when i do a report for todays, I will see todays payments, and then when tomorrow arrives, the forms that were entered (yesterday) will pop up on the daily list. Does that make sense??

I'm at a bit of a quandry as to how to do this....can anyone help?

Many thanks

Brian
 
I wouldn't bother with an extra form. If you don't want them manually entering the date, you could put a button on the existing form that advanced the date.
 
Hi pbaldy

How would I go about that? I know how to create a button in a form but wouldn't know how to get it to enter tomorrows date...what would be the expression?

Thanks!
 
At it's simplest,

Me.DateField = Date() + 1
 
OK forgive my ignorance, but where would I put that on the form? In control source of the button? Have tried it but it won't let me tick it on/off....

Will there be a conflict given that I have =Date() in the table field?

Thanks,
Brian
 
In the properties of the button, on the event tab, on the line that says "On Click", type in [Event Procedure], then click on the ellipsis to the right (...). Put that code in the VBA window where the cursor takes you.

I assume you mean that =Date() is the default value in the table? Presuming so, no, this will not conflict with that. The record will start with today's date, this will change it to tomorrow's.
 
Hi Paul

OK I've done that but now get the following error message:
"Compile error - Method or data object not found".

I posted that code exactly where the VBA window popped up - is there something I'm missing?
 
In my example, "DateField" would have to be changed to the name of your control. Typing "Me." should cause a list to drop down and filter as you type.
 
This is what the VBA window looks like (and I presume I don't put it in the immediate window)....

Private Sub Toggle17_Click()
Me.DateField = Date + 1
End Sub

The brackets after date disappear when I save it....
 
Hi Paul
Sorry I posted that last message before your reply.
I've updated DateField to Date and that seems to have done something - if i go to my table now that record is just 'blank'. I would rather a toggle button than a drop down list for date if poss...

Thanks

Brian
 
That looks correct, and the VBA window will sometimes drop the parentheses. If your field is named "Date", which is not a good idea, change to this to avoid confusion:

Me.Date = VBA.Date + 1

But I would change the name of the field if it's not too late. If it's still not working, can you post the db?
 
It works! Hallelujah....thanks very much! Access is very frustrating for the beginner I have to say but have learnt a hell of a lot in the past few days...this website makes my life a lot easier!

Thanks again - no doubt I'll be back with another query soon....!

Brian
 
I've just noticed a slight bug with this button.

I was using a toggle button with the code and when it is pressed it enters tomorrows date. However, if you unpress it (in case you make a mistake) it still enters it as tomorrows date (when I want it to go back tomorrow). I have the VBA code entered in 'On Click'....should it be entered somewhere else? I have tried using an option button as well but with no joy. Any ideas?

Many thanks
 
Hi Paul

I used the code that you gave me earlier up in the thread...I have however managed to suss out the problem by changing it to a 'Command Button', clicking Build Event, and then putting your code in there. That seemed to do the trick!

Thanks for the help tho, really appreciate it. Have learnt so much from these forums...
 
Ah, okay. With a toggle button, you can have it do something different when it goes up/down, so I didn't know if you were trying to do something like that.
 

Users who are viewing this thread

Back
Top Bottom