Increment date fields?

kbrooks

Still learning
Local time
Today, 08:03
Joined
May 15, 2001
Messages
202
I have a very simple database with only 3 fields, used to enter in the menu items (entree and full meal) for the day.
Date
Sandwich
HotPlate

I'm creating a form in a datasheet view for them to go enter in menu. They'll generally do a month at a time. What I'd like to do is have the date field automatically populate with the next date when they tab to a new record. Just to save them some time/keying. Is this possible?

Also I have other databases where a certain field will populate when you tab to a new record. But I have a problem with incomplete records. They'll tab to a new record and not really want to add a new one, so they close the form. Then I have half a record with a field or two filled in, and it's really garbage that just needs deleted (or shouldn't have been there in the first place). Is there a way to avoid that?
 
As to the first question. First off, if your field is really named Date you need to change this to something else, as Date is a reserved word in Access and its use can cause problems. In the example below I've used MealDate:

Code:
Private Sub MealDate_BeforeUpdate(Cancel As Integer)
  MealDate.DefaultValue = "#" & DateAdd("d", 1, Me.MealDate) & "#"
End Sub
 
Question # 2:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim resp As Integer
 resp = MsgBox("Do you want to save this record?", vbYesNo)
 If resp = vbNo Then
   Me.Undo
 End If
End Sub

And just a point of forum etiquette, please only post one question per thread. As you've posted it here, people coming along trying find the answer to Question # 2 will probably never come across this answer.

Linq
 

Users who are viewing this thread

Back
Top Bottom