nschroeder
nschroeder
- Local time
- Today, 07:20
- Joined
- Jan 8, 2007
- Messages
- 186
I'm creating a form tied to a table with only a date in it. The subform's table has the date and a filename as the PK (multiple files per day). The Form_Load event goes to the last record and checks the date. If it is < today's date, it creates a new record with the current date, so the first time they open the form each day, it creates a new daily record. Here's the code:
The problem is that it doesn't successfully perform the 2nd GoToRecord, and as a result, updates yesterday's record with today's date. I've toyed with this in debugger, and it's consistent no matter what the acRecordType. For example, if I switch them and go to acNewRec first, it will do so, but then won't go to acLast. I've determined that it's related to the form/subform situation, because if I remove the subform, then it works fine. I copied the code from another db where it's working fine also, but again, no subform there. What is it about the subform that could be causing this?
Thanks for any help!
Code:
Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
If FileDate.Value < Date Then ' Generate new record for today
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.FileDate = Date
Me.Dirty = False
End If
Me.AllowAdditions = False ' Only allowed through above code
End Sub
The problem is that it doesn't successfully perform the 2nd GoToRecord, and as a result, updates yesterday's record with today's date. I've toyed with this in debugger, and it's consistent no matter what the acRecordType. For example, if I switch them and go to acNewRec first, it will do so, but then won't go to acLast. I've determined that it's related to the form/subform situation, because if I remove the subform, then it works fine. I copied the code from another db where it's working fine also, but again, no subform there. What is it about the subform that could be causing this?
Thanks for any help!
Last edited: