Auto-Enter Previous Record Date (1 Viewer)

ccflyer

Registered User.
Local time
Yesterday, 17:22
Joined
Aug 12, 2005
Messages
90
Hey guys,

I've got a form that allows users to enter invoices into. On this form there is a field where the user enters the date of the invoice, and it is in turn stored into in a main table. This field is called [Invoice Date].

I want the current date to be automatically entered into this field when the form opens, but after a user enters an invoice and goes on to enter another, I want the date field to automatically use the date from the previous record. (Sometimes the users won't be entering invoices from the current date, but many in a row from a previous date).

Due to replication, the table doesnt' have a sequential autonumber field. The number is random. Any suggestions would be greatly appreciated.

Thanks,
Chris C.
 

RV

Registered User.
Local time
Today, 00:22
Joined
Feb 8, 2002
Messages
1,115
Put this code in the On Open event of your form:

Code:
Me.[Invoice Date].DefaultValue = "=#" & Format(Date, "dd-mm-yyyy") & "#"

And put this code in the Before Update event of your Invoice Date field:

Code:
Me.[Invoice Date].DefaultValue = "=#" & Format(Me.[Invoice Date], "dd-mm-yyyy") & "#"

RV
 

ccflyer

Registered User.
Local time
Yesterday, 17:22
Joined
Aug 12, 2005
Messages
90
RV, what do the # signs do?
 

RV

Registered User.
Local time
Today, 00:22
Joined
Feb 8, 2002
Messages
1,115
You need the # signs in VBA to identify your variable as a date string.

RV
 

ccflyer

Registered User.
Local time
Yesterday, 17:22
Joined
Aug 12, 2005
Messages
90
Thanks RV!!, that worked perfectly.

-Chris C.
 

Users who are viewing this thread

Top Bottom