nschroeder
nschroeder
- Local time
- Today, 15:19
- Joined
- Jan 8, 2007
- Messages
- 186
Greetings. I have a form that automatically creates a new record each day, the first time the form is opened that day. Code in the Form_Load event checks the date value in the last record of the table, and if it is less than the current date, it creates the new record. Otherwise, it stays on the last record. Here's the code:
This has been working fine in Access 2003, but in 2010 the acNewRec command doesn't work. Stepping through the debugger, it correctly goes to the last record after the acLast command, but after the acNewRec, it still points to the last record (PODDate still contains yesterday's date), even though no error seems to have occurred. It then updates yesterday's record with today's date, which forces me to have to go into the table every day and fix it. When I step through the 2003 version, PODDate contains null after the acNewRec command, as it should.
We have mixed (2003/2010) users accessing the database, and either one could be the first to open the form. Any help would be appreciated.
Code:
Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
If PODDate.Value < Date And _
Weekday(Date) > 1 And Weekday(Date) < 7 Then ' No record yet today, and not a weekend
DoCmd.GoToRecord , , acNewRec
PODDate.Value = Date
End If
End Sub
This has been working fine in Access 2003, but in 2010 the acNewRec command doesn't work. Stepping through the debugger, it correctly goes to the last record after the acLast command, but after the acNewRec, it still points to the last record (PODDate still contains yesterday's date), even though no error seems to have occurred. It then updates yesterday's record with today's date, which forces me to have to go into the table every day and fix it. When I step through the 2003 version, PODDate contains null after the acNewRec command, as it should.
We have mixed (2003/2010) users accessing the database, and either one could be the first to open the form. Any help would be appreciated.