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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidAustin
    New Member
    • Nov 2014
    • 64

    #1

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

    Hi all,

    My data entry form wont allow me to add a new record. It brings up an error on the DoCmd.GoToRecor d , , 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!

    Code:
    Private Sub cmdAddFile_Click()
    
    Dim intResponse As Integer
    
        If validAddForm = True Then
            DoCmd.RunCommand acCmdSaveRecord
            DoCmd.GoToRecord , , acNewRec
        Else
            MsgBox "This record is incomplete." & vbCrLf & "You have not included:" & vbCrLf & strInvalid, vbExclamation + vbOKOnly, "Adding Record: Incomplete"
        End If
    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!
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    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!

    Comment

    Working...