By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,121 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,121 IT Pros & Developers. It's quick & easy.

Auto Date in form "pages"

P: 29
I have a form set up like a journal

the top of the page has

2 fields

dateID {autonumber)
Date (date/time)

under these there is a subform with ny notes section

i would like to have the date change from todays date to tommorrows date on the next page

how do i do this
Dec 30 '08 #1
Share this Question
Share on Google+
6 Replies


Expert 100+
P: 112
This depends on what you mean by change page, and how you are doing that. It sounds like you need to respond to whatever event a page change is and populate the appropriate control or record with today's date. the Functions Now or Date will return today's date. If you add a few more details we can probably zero in on what you need.
Dec 30 '08 #2

P: 29
first off thanks for replying


2nd

i think what i am getting at is

i want 2 forms. they are:

1 main for and a sub form
on the main form i have a date box call it txt_date
further down the form is a sub form called Subform_Memo

when ever i click to a new record on the main form i want the date to be 1 day after the last record

i never want a day to be missed so a default value of Date() wont work. also i never want a date to repeat so there should never be 2 December 29 2008 ... so i indexed the field making duplicates allowed (no)

they real issue i have is that the next record of the main form as of writing is not taking the next possible day ie December 30th 2008

i hope im being clear enough i am having trouble explaining it:)

if i click new record 3 times in a row the date should change from
December 29
December 30
december 31

etc even if the date is december 29th
Dec 30 '08 #3

Expert 100+
P: 112
You can create a variable that holds today's date when the form opens. Then whatever triggers a new record or page change can increment this variable i.e.
Expand|Select|Wrap|Line Numbers
  1. dim dte as date
  2. sub form_open
  3.      dte = date
  4. end sub
  5.  
  6. sub newpage()
  7.      dte = dte + 1
  8. end sub
  9.  
If today's date is too general as a starting point you can populate the variable from wherever you are storing the dates (i.e. the maximum date value from the table the dates are contained in).
Hopefully I understood you correctly, if not, let me know and I'll try again ;-)
Dec 30 '08 #4

P: 29
hate to sound new to VbA but it has been a while

If i put that code in the On load event i get an error.

i dim dte as date over the sub
enter the code in the sub and then end the sub

but it is popping up error

i should pull out my books and reread the coding sections


but it looks like that might work.. only thing i want it to do is call the last date entered and add 1 day so i never miss a day even if i havent opened it in 3 days i need to be forced to fill in the missing days
Dec 30 '08 #5

Expert 100+
P: 112
What does the error message say?
Dec 30 '08 #6

missinglinq
Expert 2.5K+
P: 3,532
I think this will do the job. Where

TableDateField is the field that txt_Date is bound to

and

YourTable is the actual name of your underlying table

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord Then
  3.   If IsNull(DMax("[TableDateField]", "YourTable")) Then
  4.    Me.txt_Date = Date
  5.   Else
  6.    Me.txt_Date = DMax("[TableDateField]", "YourTable") + 1
  7.   End If
  8. End If
  9. End Sub
Linq ;0)>
Dec 31 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.