Increment date: previous date +1 ?

Dick de Jong

Registered User.
Local time
Today, 20:20
Joined
Aug 24, 2003
Messages
10
Very simple question: I just moved a simple daily rainfall record spreadsheet to my Access gardening database. Fields are date, rainfall in mm, temperature etc. and a single record is added for each day. How do I get the date field to increment automatically to 'previous day's date +1'. (No, I cannot use the shortcut key [Cntrl-;] to insert today's date in the table because records are only entered periodically, several days at a time, from a notebook.) Advice appreciated.
 
This is for use on a form as a bit confussed?

what you could do is add a default for todays date IE Default Value on form =Date()

Then use This which will use the plus and minus buttons while the date field has the focus IE Clck the date field sets that field as got focus

Code:
Select Case KeyCode
    Case 107, 187                   '"+" Key
    ConsultDate = ConsultDate + 1   'Increment The Date
    SendKeys "{Esc}"                'Undo Keystroke
    Case 109, 189                   '"_" Key
    ConsultDate = ConsultDate - 1 'Change ConsultDate to name of your form field
End Select
 
SendKeys "{Esc}" surely that's a throwback to 95?:eek:

I was wondering why it was there but had that hanging round for years if I remember it came from a 95 example book maybe I'll get around to removing it ;)
 
Put this in the OnEnter for the date field, or any other event that might be appropriat

me.datefieldname = Dmax("[yourdatefield]","[yourtable]")+1
 
One method, could be to stuff the last edited date + 1 into the default value property of the control. I e, in the after update event of the control

Me!txtSomeDate.DefaultValue = "#" & Format(Me!txtSomeDate.Value +1, "yyyy-mm-dd") & "#"
 
Wow, thanks for all the responses. I think I've jumped into the deep end - I'm comfortable with tables, queries & reports, and the relational model, but have no prgramming expertise. I thought there might be a simple function in a data entry query that would give me the next day's date each time I add a new record. I will work through all your kind responses and see if I can find something to do that. Will report back.
 
Use the DateAdd function in an append query

Rich: Thank you but my understanding of an append query is to add a whole batch of records to the end of an existing table.
I enter each day’s meteorological data individually starting with entering the day’s date. I do not see how an append query helps but suppose that reflects my limited knowledge.
I read the Access 2K Help item on DataAdd Function Example and do not see how I can apply it to this problem.
 
what you could do is add a default for todays date IE Default Value on form =Date()
Then use This which will use the plus and minus buttons while the date field has the focus IE Clck the date field sets that field as got focus
Code:
 ...

Thanks, Dreamweaver, but its way too deep for this end-user.

[QUOTE Access 2002 AND 2003, VB6 , mysql, PHP, .net, HTML ][/QUOTE]
Hmm, we’re very primative here, still on Access 2000 & Pentium III.. Sigh.
 
Put this in the OnEnter for the date field, or any other event that might be appropriat

me.datefieldname = Dmax("[yourdatefield]","[yourtable]")+1

Thanks Fred. I tried this. It seems to require a form which I had not thought I needed but made one for this purpose. Found the OnEnter in the properties, entered the local version of your <<me.datefieldname = Dmax("[yourdatefield]","[yourtable]")+1>> viz. << me.date=Dmax("[date]","[tblWeather_at_No_34]"+1 >> but then realised from the 'me' that then needs to read a macro…. which is beyond this end-user. I suppose I could study & learn about those, but life’s too short. Curiously the Access 2K Help on Dmax says it can be used in a query expression, which is something I have used quite a bit, but I was unable to get it to increment my date field. Back to typing the day’s date in manually.
 
Increment date: previous date +1 ?

Nope, you guys are too deep for this end-user. I only wanted to increment the date field, in a table, or at the most in a select query, just like an Autonumber increments itself, to save me typing in the date each time I add a record at the bottom. You guys seem to be offering a Boeing 747 to post a letter down the road. But perhaps that's Access. Thanks for all your time.
 

Users who are viewing this thread

Back
Top Bottom