Auto populate month & year

  • Thread starter Thread starter Garu
  • Start date Start date
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
 
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
 
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
'====================================================
 
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
 
Back
Top