You can't go to the specified record error

H

hollyylloh

I have been stairing at this for awhile and don't see the problem. I hope you
can help. I added all the msgboxs just to narrow the error down.

I have the following code:

Private Sub Form_Current()
'the form checks the subform to see if there are any records present.
With Me![qryNewCompanyNameIsLike subform].Form

If .RecordsetClone.RecordCount = 0 Then

'if no records are present in the subform, it pastes the record into a table
named tblToExport

MsgBox "is Null"
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
MsgBox "copied"
DoCmd.OpenTable "tblToExport"
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
DoCmd.GoToRecord , , acNext
MsgBox "go to next tblToExport record"
DoCmd.OpenForm "frmImportedIsLike"
MsgBox "pasted and back"
DoCmd.GoToControl "Company"
MsgBox "go to company"
DoCmd.GoToRecord , , acNext
MsgBox "go to next"

-------I get the error here----"You can't go the the specified record." I
get this error after it goes to the next record.

End If

End With
End sub
 
H

hollyylloh

I removed the code from the on current event property and added a loop, and
the code works as is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top