New record, last date +1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a form with a date field. I want that when I open a new record it
looks for last date in previouse record and then add 1 day. I am shore it is
some simple one that I have not found out.

//Robert
 
hi Rob,
I have a form with a date field. I want that when I open a new record it
looks for last date in previouse record and then add 1 day.
Depends on your definition of "previous record". If you have an
autoincrement primary key, this may work:

CDate(DLookup("DateField", "Table", "ID = " & _
DMax("ID", "Table") + 1)



mfG
--> stefan <--
 
hi,
Depends on your definition of "previous record". If you have an
autoincrement primary key, this may work:

CDate(DLookup("DateField", "Table", "ID = " & _
DMax("ID", "Table") + 1)
There is a ) missing:

CDate(DLookup("Date", "Table", "ID=" & DMax(..)) + 1)

mfG
--> stefan <--
 
Hi Stefan

I put in the date myself in the field. I only want that when I create a new
record I automaticlly get the date after the last I filled in or got by auto.

//Robert

"Stefan Hoffmann" skrev:
 
By "the last I filled in or got by auto" do you mean the record with the
most recent date? If so, your form's Current event could be:
If Me.NewRecord Then
Me.DateField = DMax("DateField","TableName") + 1
End If

The expression DMax("DateField","TableName") + 1 could also be used as the
default value for DateField. In either case, each new record will have a
date one greater than the previous most recent date. If you create ten
records during one day, you will have ten sequential dates in that field.
Is that your intention?
 
Thank you all. It works create

"BruceM" skrev:
By "the last I filled in or got by auto" do you mean the record with the
most recent date? If so, your form's Current event could be:
If Me.NewRecord Then
Me.DateField = DMax("DateField","TableName") + 1
End If

The expression DMax("DateField","TableName") + 1 could also be used as the
default value for DateField. In either case, each new record will have a
date one greater than the previous most recent date. If you create ten
records during one day, you will have ten sequential dates in that field.
Is that your intention?
 
Back
Top