DoCmd.GoToRecord acNewRec not working on subform
Posted on 2006-05-03
I have the following code:
If Me.subform_other.Form.RecordsetClone.RecordCount = 0 Then
DoCmd.GoToRecord , , acNewRec
I get a run time error 2105, "You can't go to the specified record." I think it is because I have the Allow Additions property set to NO for the subform. I have that function disabled to prevent users from being able to add records on the subform by just rolling the mousewheel.
What is happening here is the main form has a record, but that record does not have an associated record in the subform, so when the form opens some of my code fails that tries to refer to the data on that subform. The code works if there is a blank record there, so I just thought I would add a record if the system didn't find one on form_current.
What I need is either:
1. A way to add a record to the subform if one isn't present on form_current.
2. A way to disable the mouse wheel functionality, so I can Allow Additions again. I found very complicated ways of disabling the mouse wheel, so I just decided it was simpler to add a record.