Full Version: New Date In Sequential Order
UtterAccess Forums > MicrosoftŪ Access > Access Forms
tomfernandez12004
Hello,

I have a form that has a date field [TicketDate] along with other fields. If TicketDate is 2/1/15, then I would like this field on the next (new) record to show 2/2/15. Is there a VBA way to do this?

Thank you.
-Tommy
theDBguy
Try the DefaultValue property in VBA.
missinglinq
Along with DMax() + 1 against the date field.

Linq ;0)>
tomfernandez12004
Just returned to the office.. Thanks for the replies, all!

missinglinq - where would I insert " DMax() + 1"?

-Tommy
ScottGem
Can you explain this in more detail.

What happens if 5 records are entered on the same day, will they all have an incremented date? What is the significance of the date field.

While you can use a DMax to insert a date sequence, I question the value of one without knowing more.
tomfernandez12004
ScotGem - records do get entered daily, but sometimes get entered at the end of a week. It would save time having new [TicketDate] show the following day.

-Tommy
ScottGem
So the date could be overidden?

Set the Default value of the control to:

=DMAX("[datefield]","tablename")+1
tomfernandez12004
ScottGem - yes, date can be overidden. I set control default value to "=DMAX("[datefield]","tablename")+1"

Interestingly, datefield for new record matches previous datefield value, but then increments on the next new record. Here is the sequence: 1/2/15, 1/2/15, 1/3/15, 1/3/15, 1/4/15....

Any idea why this happens?

-Tommy
ScottGem
Try =DateAdd("d",1,DMax([datefield],"tablename"))

Not sure why the other won't work,.
tomfernandez12004
ScottGem - I tried =DateAdd("d",1,DMax([datefield],"tablename")) and get an "Error" displayed in the date field. Strange?

-Tommy
ScottGem
Can I assume you used the correct field and tablenames?
tomfernandez12004
ScottGem - field name and table name are correct. I will test on different database to be sure.

Thank you.

-Tommy
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.