Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date populates +1 at next record

Status
Not open for further replies.

Roblin

Technical User
Feb 3, 2005
26
0
0
US
I am building a database and have run into a problem. I have form with a combo box named cboDate that uses a pop up calender to choose a start date. There are four other fields in the form - projectcodeAM, functionAM, projectcodePM and functionPM. This DB tracks half days of employees time. Each employee will have their form point to a back end DB on a network drive that will store thier data. Once the form in opened and the start date is selected from the pop up calendar, I would like the next date to populate without having to choose the date from the pop-up calendar again. I have tried cboDate.value + 1 but the date disappears at the next record. I have also tried putting adding one to the value in the cmdbutton that moves to the next record and that doesn't work. It will work if I take out docmd.gotorecord,,acnext. But then I can't go to the next record. I've tried many different things and searched all the other posts, but they don't seem to work for me. Any suggestions?
 
Try adding this to an event -

cboDate.Value = cboDate.Value + 1

Only dead fish (and shit) go with the flow!
 
Perhaps this before going to new record:
cboDate.DefaultValue = cboDate.Value + 1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you both for your responses. I had some luck with adding cboDate.DefaultValue = cboDate.Value + 1 before docmd.gotonextrecord,,acnext. Although, after the button is clicked to go to the next record, the date for the next record is "Saturday, December 30th, 1899". Then if the form is completed again and you click the button to go to the next record the box is populated with "#Name?". I read some of the posts regarding that date but nothing seems to work. Any Ideas? Thanks again!
 
Thanks both of you. I finally figured it out:
Dim NextDate As Date
NextDate = cboStartDate

DoCmd.GoToRecord , , acNext

If NewRecord Then
cboStartDate.Value = NextDate + 1
End If

I don't know much about code, but I played around with it a bit and this works. Thanks agagin.
 
Roblin,
This is EXACTLY what I've been looking for![thumbsup2] What event did you put this in?
 
MelissaKT,

I put it in the click event for a button that the user hits to advance to the next record. Glad this helped you too!!
 
... and look at the DateAdd function...
Code:
If IsDate(cboStartDate.Value) Then
   Me.cboStartDate.Default = DateAdd("d", 1, Me.cboStartDate)
Else
   Me.cboStartDate.Default = Date
End If

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top