Auto populate month & year

G

Garu

Hi,

I have a table with 'mnth' and 'yr' columns and what I would like them to
auto populate secquentially based on the value of 'mnth' and 'yr' entered
as first record.

To illustrate, assumming on the first record the user enters mnth="November"
and yr="2008" then the next record to be created will auto populate to
"December" and "2008", then next record will be "January" and "2008" and so
on and so forth...

Hope you got my point.

Garu
 
T

TedMi

Much better to have a single field of type DATE, say MyDate. In reports, you
can display MonthName(Month(MyDate)) and Year(MyDate), which will give you
what you want.
Assuming that each new record is to be dated one month after the last-dated
record:
Enter all the fields of the new record EXCEPT the MyDate field, then run
this query:
UPDATE MyTable SET MyDate = DateAdd("m", 1, DMax("MyDate", "MyTable")) WHERE
MyDate IS NULL

-TedMi
 
J

John Spencer

Unfortunately that query will probably give you the same date for every
record where the date is null.


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
G

Garu

Thanks, that pretty much gave me the idea.

TedMi said:
Much better to have a single field of type DATE, say MyDate. In reports,
you can display MonthName(Month(MyDate)) and Year(MyDate), which will give
you what you want.
Assuming that each new record is to be dated one month after the
last-dated record:
Enter all the fields of the new record EXCEPT the MyDate field, then run
this query:
UPDATE MyTable SET MyDate = DateAdd("m", 1, DMax("MyDate", "MyTable"))
WHERE MyDate IS NULL

-TedMi
 

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