469,165 Members | 2,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,165 developers. It's quick & easy.

Auto Date in form "pages"

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
6 1376
112 Expert 100+
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
first off thanks for replying


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
112 Expert 100+
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
  6. sub newpage()
  7.      dte = dte + 1
  8. end sub
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
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
112 Expert 100+
What does the error message say?
Dec 30 '08 #6
3,532 Expert 2GB
I think this will do the job. Where

TableDateField is the field that txt_Date is bound to


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.

Similar topics

6 posts views Thread by Josť Joye | last post: by
3 posts views Thread by Nils Magnus Englund | last post: by
2 posts views Thread by Wade | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.