Sequential Dates

  • Thread starter Thread starter Joe Mama
  • Start date Start date
J

Joe Mama

After sorting my database by department, as I enter new
records, I want the first field "Date" to enter the next
date from the last record. If the last entry
is "4/30/2004", the the next record should be "5/1/2004",
the next record "5/2" etc. I've tried expression
building, queries, but I just don't get it. Help!
 
Joe,

In the design view of your form, set the Default Value property of the
Date control to the equivalent of...
DMax("[Date]","NameOfYourTable")+1
This will work if you are using a singel view form. If you are using a
continuous view form, I think the best way is to put a vba procedure on
the Before Insert event of the form, like this...
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![Date] = DMax("[Date]","NameOfYourTable") + 1
End Sub

By the way, as an aside, the word 'Date' has a special meaning in Access
(it is classified as a 'reserved word') and as such should not be used
as the name of a field or control or database object. I recommend
changing this.
 
I guess I should have mentioned that I like to enter new
records in the table view. I filter the table by an
individual department (numerous dept. in the table) that
comes up in date order. With the last date showing as
say "4/30/2004", is there a way for the next record to go
up by 1 automatically?
Thanx
-----Original Message-----
Joe,

In the design view of your form, set the Default Value property of the
Date control to the equivalent of...
DMax("[Date]","NameOfYourTable")+1
This will work if you are using a singel view form. If you are using a
continuous view form, I think the best way is to put a vba procedure on
the Before Insert event of the form, like this...
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![Date] = DMax("[Date]","NameOfYourTable") + 1
End Sub

By the way, as an aside, the word 'Date' has a special meaning in Access
(it is classified as a 'reserved word') and as such should not be used
as the name of a field or control or database object. I recommend
changing this.

--
Steve Schapel, Microsoft Access MVP


Joe said:
After sorting my database by department, as I enter new
records, I want the first field "Date" to enter the next
date from the last record. If the last entry
is "4/30/2004", the the next record should be "5/1/2004",
the next record "5/2" etc. I've tried expression
building, queries, but I just don't get it. Help!
.
 
Joe,

The purpose of tables is background storage of data, and should normally
only be seen during the design and debugging phases of database
development. Whereas it is theoretically possible to use them for data
entry/editing, there are many problems associated with this approach,
not the least of which is the limited functionality available for the
kinds of thing you are trying to do. The database object which is
applicable for entry, editing, and viewing of data is the Form.
 
Back
Top