Error Code 2105

basilyos

Registered User.
Local time
Yesterday, 21:56
Joined
Jan 13, 2014
Messages
256
hello guys,


i have a form that is bound to a table


am let the form go to the last record then showing a message to let the client now the number of the last file saved then push the form to go to a new record so the client continue saving new files

Code:
Private Sub Form_Load()

    DoCmd.GoToRecord , , acLast
    MsgBox ("the last Saved File Was Number " & Me.txt_Record_Number)
    DoCmd.GoToRecord , , acNewRec
    
End Sub
this is what am getting when the form load


Run-time error '2105'
You Can't go to the specified record


and when i debug am going to this line


Code:
DoCmd.GoToRecord , , acNewRec
any help ?
 
How are you opening the form, and do you have it set to data entry = Yes in design mode?
 
Also is Allow Additions set to Yes, and does the record source of the form allow new records to be added directly if it's a query?
 
am opening the form from another form using this command


Code:
DoCmd.OpenForm "frm_Personal_Sanctions_Entry", acNormal, , "[PID] = " & [PID]


Data Entry set to no
Allow Additions set to yes
 
am filtering the form using PID coz every client have his own files to save
 
I think a filtered form won't let you go to a new record, as the new record won't have the PID you are requesting.

Personally I think you'd be better off getting the last Record ID using a DLookup, and just opening the form directly on a new record.
 
In an extremely brief test, a form based on a table opened with a wherecondition still allowed new records. Can yo attach your db here?
 
i attached a small copy of my database i hope could some one help me
 

Attachments

For chuckles, tried this which also works, which again points to the message box:

Code:
    Dim lngNumber             As Long
    
    DoCmd.GoToRecord , , acLast
    lngNumber = Me.txt_Record_Number
    DoCmd.GoToRecord , , acNewRec
    MsgBox lngNumber
 
For chuckles, tried this which also works, which again points to the message box:

Code:
    Dim lngNumber             As Long
    
    DoCmd.GoToRecord , , acLast
    lngNumber = Me.txt_Record_Number
    DoCmd.GoToRecord , , acNewRec
    MsgBox lngNumber


thank you so much
 
No problem. It is curious that having the message box before the GoToRecord causes the error.
 
No problem. It is curious that having the message box before the GoToRecord causes the error.

That is weird. Good spot though.
I wonder if the handler for the message box causes some strange record lock somehow?
 
..
I wonder if the handler for the message box causes some strange record lock somehow?
No, but the focus move away from the form, so if you've have "Me.SetFocus" just before "DoCmd.GoToRecord" the problem is gone.
 
No, but the focus move away from the form, so if you've have "Me.SetFocus" just before "DoCmd.GoToRecord" the problem is gone.

Ah, so it does. Good catch! I hadn't considered that.
 

Users who are viewing this thread

Back
Top Bottom