423,516 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

Runtime Error 2105 You Can't Go to the specified record

P: 64
Hi all,

My data entry form wont allow me to add a new record. It brings up an error on the DoCmd.GoToRecord , , acNewRec line. The form is set to Allow Additons and Data Entry to Yes. I thought that it may have been not saving the record properly but after inserting the save record command it has saved to the table as expected. validAddForm is a function that holds my validation rules and is tested in the Before_Update of the form. If true, then the record has passed validation.

I can't work out why this "You can't Go to the specified record" error is happening! All help is most appreciated as always!

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddFile_Click()
  2.  
  3. Dim intResponse As Integer
  4.  
  5.     If validAddForm = True Then
  6.         DoCmd.RunCommand acCmdSaveRecord
  7.         DoCmd.GoToRecord , , acNewRec
  8.     Else
  9.         MsgBox "This record is incomplete." & vbCrLf & "You have not included:" & vbCrLf & strInvalid, vbExclamation + vbOKOnly, "Adding Record: Incomplete"
  10.     End If
  11. End Sub
Edit: When in form view, if I switch to datasheet view and then back into form view, the record can then be added. The acCmdSaveRecord saves the record correctly but then the error pops up saying that it can't go to the next record!
Jan 23 '15 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 2,608
David,

I would suggest adding a validation to the AfterUpdate events of your text boxes. Whenever a user updates any value, run the validation. If the validation passed, then enable the cmdAddFile button. If it fails validation, then disable the button. I can't explain "why" but sometimes Access gets confused during such operations (I've done similar things with identical results). However, this work-around is actually better coding, as you are validating data as you go along and only allowing users to move to the next step once all data is valid.

Hope this hepps!
Feb 25 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.