Update -- still not wor.. waitasec. Fixed!
I don't fully understand jbrabek's suggestion, as there is no member named "fldkey" and I've never seen it used as pseudocode parlance. I've tried re-setting linkchildfield and linkmasterfield to the field name, but this crashes the form because the main form contains several unfilled "not null" fields. For the same reason, I would not be able to move forward and back as per CRC's suggestion. I've also tried directly setting the subform's foreign key to the main form's primary key, but this steals the last form's subform data records and points them to the current form; not the result I want. I've only tried these in _current(), not _after_update(), but I don't expect much to change.
Some more detail on my situation: The main form has a button to turn editing on or off. Editing is kept off by default so users don't screw up old records. I have a setEdits() subroutine which handles turning edit mode on and changing the button to say "start editing" or "stop editing". I've tracked the problem down to the AllowEdits = True line in this function. Also, Form_current() makes some ornamental changes to the form and turns off editing mode.
Finally got it fixed as I was typing this (funny the way that works).
Here's my code. Note that setEdits() needs to be passed False *and* NewRecord to be false to turn off the form's edit mode, since you can't turn editing off on a new record:
\nPrivate Sub setEdits(okay As Boolean)\n' utility function to switch editing mode on or off\n' No other code should change AllowEdits\n\n If (okay = False And NewRecord = False) Then\n Call DoCmd.RunCommand(acCmdSaveRecord)\n AllowEdits = False\n SurveyRequest_Roads.Form.AllowEdits = False\n SurveyRequest_Roads.Form.AllowAdditions = False\n EditRequest.Caption = "Start Editing"\n Else\n AllowEdits = True\n AllowAdditions = True\n SurveyRequest_Roads.Form.AllowEdits = True\n SurveyRequest_Roads.Form.AllowAdditions = True\n EditRequest.Caption = "End Editing"\n ' Reset projects rowsources to default\n Project.RowSource = "SELECT Name FROM project"\n JobNo.RowSource = "SELECT id FROM project"\n End If\nEnd Sub\n\nPrivate Sub Form_Current()\n\n ' Auto-fill unlinked fields\n Call setEdits(True) ' turn on edits first\n Call checkTree ' Set unlinked checkboxes\n Call JobNo_AfterUpdate ' Set project name\n\n ' Hide the debugging stuff, but leave the code in\n If (txtVerticalDatum.Visible) Then\n Call Flip_Hidden\n btnHidden.Visible = False\n End If\n\n ' Special logic for new records\n If (NewRecord) Then\n ' Automatically fill in some fields\n DateRequired.Value = Date\n ' Go to a data input field, preferably a required value\n Call DoCmd.GoToControl("RequestedBy")\n Else\n Call setEdits(False) ' turn off edits\n End If\nEnd Sub\n
The form has unlinked checkboxes and things that are there to make it look pretty. I need to turn on AllowEdits to make these work, but then need to turn it off so old records don't get accidentally modified.
The second call to setEdits() in form_current() used to be outside the if(NewRecord) branch, under the assumption that it wouldn't make a difference. After all, if NewRecord is true, then setEdits(False) would have the same result as the setEdits(True) call at the beginning of _current(), right? Wrong.
Don't ask me what happened, but the form seems to be working now. I just need to check to make sure I didn't break it somewhere else. Thanks for the suggestions that everyone offered.