Automatic date entry in new record

S

Seph

I have a form for a 2 week pay period.
I have a field "PayPeriodStartDate" which is always 14 days later than the
previous record's "PayPeriodStartDate".
I would like to have the date automatically entered when a new record is
opened, but can't figure out how to do it.
Any suggestions?
 
B

Beetle

You can use DMax to get the most recent start date from the
table and DateAdd to add 14 days to that value. For example;

DateAdd("d", 14, DMax("[PayPeriodStartDate]", "tblYourTable"))

You could do this in code in the Current event of your form, or use
it as the default value in the properties of your text box on the form
(put the = sign in front of it if you do that).
 
M

Mike Painter

Seph said:
I have a form for a 2 week pay period.
I have a field "PayPeriodStartDate" which is always 14 days later
than the previous record's "PayPeriodStartDate".
I would like to have the date automatically entered when a new record
is opened, but can't figure out how to do it.
Any suggestions?

You can use dLookup, dLast,or dMax.
All take pretty much the same format.
DLast(dateAdd("d",14,PayPeriodStartDate, "YourForm", "EmployeeID =" &
EmpID)
It can also be done with the tag property.

This has been one of my pet peeves in Access since I started using it with
version two.
Ctrl + apostrophe shows that teh value is always available to Access.
I think that should be exposed so we could use Me.ThisField.PreviousValue.

Of course if they were really cleveer we could apply Thiotimoline and get
Me.ThisField.NextValue
http://preem.tejat.net/~tseng/Asimov/Stories/Story271.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top