Link to home
Start Free TrialLog in
Avatar of billcute
billcute

asked on

"You cant go to the Specified Record" Error

After filling out all the three Pages of my form, user clicked the AddNew button in order to advance to a new record...user started to receive...
"You cant go to the specified record" and unable to save the current record.

..debug highlighted from the code below
DoCmd.GoToRecord , "frmSewer", acNewRec

Any suggestion in correcting this problem will be appreciated.
' ***********************************
Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click

 If Not MandatoryFields Then    ' <---Check for Mandatory Fields
      Exit Sub
  End If
         
 Call SaveCurrentControlValues            ' For Autofill Routine
' *******************************
   If Me.AllowAdditions = False Then Me.AllowAdditions = True
  Me.Filter = ""
  Me.FilterOn = False
 
  If Me.NewRecord Then
    DoCmd.GoToRecord , "frmSewer", acNewRec
    Call QuestionBox
    Me.txtAppEntryDate.SetFocus
 End If
Exit_btnAddNew_Click:
     Exit Sub
Err_btnAddNew_Click:
     MsgBox Err.Description
    Resume Exit_btnAddNew_Click
    End Sub
Avatar of clarkscott
clarkscott
Flag of United States of America image

You may have fields that are REQUIRED.   Try this, open the recordset in datasheet mode (directly into the table) and enter the exact data you would if from the form.  Access will immediately tell you why you can't add record.

Scott C.
Avatar of billcute
billcute

ASKER

Scott,
I added the data directly to the table as suggested and there was no problem adding them. I suppect that the error is with this line code ofmy btnAddNew:

DoCmd.GoToRecord , "frmSewer", acNewRec

Regards,
Bill
Hi Bill,
Try changing this:
  If Me.NewRecord Then
    DoCmd.GoToRecord , "frmSewer", acNewRec
    Call QuestionBox
    Me.txtAppEntryDate.SetFocus
 End If

   
to this:
    DoCmd.GoToRecord , "frmSewer", acNewRec
    Call QuestionBox
    Me.txtAppEntryDate.SetFocus

how can you go to new record if the current record is a new record?

puppydogbuddy,
When I rem out this line code...it made no difference

If Me.NewRecord Then
ASKER CERTIFIED SOLUTION
Avatar of clarkscott
clarkscott
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
move this:
 Call SaveCurrentControlValues            ' For Autofill Routine

To here:
DoCmd.GoToRecord , "frmSewer", acNewRec
 Call SaveCurrentControlValues            ' For Autofill Routine

can't call autofill until you new record has focus.
Scott,
I think I have an idea of what you are talking about. Yes, I recently joined several tables in the control source of my main form - I am sure this may be responsible for the problem. Thanks

If you have more time I can explore this your other suggestion..

"..You may need to add a SAVE button that, in code, you add/update records per specific tables using the text (or combo selctions) in your form"

Regards
Bill
puppydogbuddy ,
I think Scott is right...I checked it out...and found the "joins" to be cause of the problem...I will need to post a new question later in order to explore other alternatives around the joins.

Regards
Bill