I'm experiencing a problem that would make me pull my hair out if I had any. I have a form that displays records (FOB's) in a subform datasheet. I have code setup so when I push "ctrl-d" it runs some delete code which in turn opens another form that forces you to select a different FOB to assign to any detail records that have the FOB that is being deleted. After I delete said FOB the form has to refresh of course and then move back to the same row as the previously deleted record. This is the code I'm trying to use to do this functionality.
Now, when I run this code and it hits the GoToRecord line it comes back with the error "You can't go to the specified record". Any thoughts? BTW, the FOB in this line "Forms!frm_FOB!chd_FOB.Form.FOB.SetFocus" is actually a field name.
Code:
Dim int_Row As Integer
Dim I As Integer
int_Row = Forms!frm_FOB!chd_FOB.Form.CurrentRecord
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tbl_Manufacturer set FOB_ID = " & Me.cbo_ID.Value & " where FOB_ID = " & [Forms]![frm_FOB]![chd_FOB].[Form]![txt_ID]
DoCmd.RunSQL "Delete from tbl_FOB where ID = " & [Forms]![frm_FOB]![chd_FOB].[Form]![txt_ID]
Forms!frm_FOB!chd_FOB.Form.Requery
Forms!frm_FOB!chd_FOB.SetFocus
Forms!frm_FOB!chd_FOB.Form.FOB.SetFocus
For I = 0 To (int_Row - 2)
DoCmd.GoToRecord acActiveDataObject, , acNext
Next
Now, when I run this code and it hits the GoToRecord line it comes back with the error "You can't go to the specified record". Any thoughts? BTW, the FOB in this line "Forms!frm_FOB!chd_FOB.Form.FOB.SetFocus" is actually a field name.