PC Review


Reply
Thread Tools Rate Thread

automatic enter a date plus one day from the previous record

 
 
Bill
Guest
Posts: n/a
 
      4th Nov 2008
I use a data base using the date as the indexI want to automatically enter
previous date plus one day on my data entry form at new record creation. is
there an easy way ?
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      5th Nov 2008
Use the BeforeInsert event procedure to look up the highest date so far, and
enter the next value.

This example assumes the field/control is named Date1, and comes from
Table1:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim varResult As Variant

If Not Form.ActiveControl Is Me.Date1 Then
varResult = DMax("Date1", "Table1")
If IsDate(varResult) Then
Me.Date1 = varResult + 1
End If
End If
End Sub

(Note that the code avoids assigning the date if Date1 is the active
control, as it gets really confusing if the user is trying to type something
into that box and another value suddenly shows up.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bill" <(E-Mail Removed)> wrote in message
news:7225D979-FC8B-46CF-82DB-(E-Mail Removed)...
>I use a data base using the date as the indexI want to automatically enter
> previous date plus one day on my data entry form at new record creation.
> is
> there an easy way ?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Verifying a Date from previous record before allowing new record a Devon Microsoft Access Form Coding 2 14th Jul 2009 02:56 PM
automatic entry of previous record Bill Microsoft Access Database Table Design 1 4th Nov 2008 09:29 PM
Enter Data Based on Previous Record Sherry N. Microsoft Access Form Coding 19 14th Jul 2008 02:27 PM
Access forms - automatically enter data from the previous record? =?Utf-8?B?U3Rhbg==?= Microsoft Access Forms 1 31st Mar 2006 12:57 AM
Enter date from previous record to new record Randy Microsoft Access Forms 4 18th May 2005 12:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:07 PM.