Error 2105 and 2106

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 01:44
Joined
Dec 24, 2018
Messages
150
Access Heavyweights,

I was building the buttons, controls and events one by one in a form and all was good. When I came to the the last button (cmdSave) the form start returning the "Error 2105: You Can´t Go to the Specified Record" on a the navigation buttons:Next, Previous, First and Last. And "Error 2046: The command or action SaveRecord isn´t available now" on the cmdSave code too...

I had to rebuild from scratch and again before adding the cmdSave code all was working fine, once I added the cmdSave code all was wrecked.

Even if I remove the cmdSave code it won´t work and keeps returning the same errors.

The DB is attached, the problem is on the frmCardObservation, the login id "Diogo" and password is 0319.

Can somebody point me what i have done wrong?
 

Attachments

The problem is that the form is in Edit Mode when you press the button.
You can test the above statement by adding the below code:
Code:
Private Sub cmdNext_Click()
'On Error GoTo Err_Handler:
 If Me.Dirty Then
  Me.Undo
 End If
 DoCmd.GoToRecord , , acNext
..
 
Login form keeps telling me Diogo already logged in.

Test if form is on first or last record before moving. Here's how I handle custom navigation buttons:

Code:
Private Sub btnNext_Click()
Me.btnViewLabData.SetFocus
Call ViewData("Next")
End Sub
 
Private Sub btnPrevious_Click()
Me.btnViewLabData.SetFocus
Call ViewData("Previous")
End Sub
 
Private Sub btnQuit_Click()
Call ViewData("Quit")
End Sub
 
Public Sub ViewData(strDirection)
'called by form to navigate records
With Form_SampleInfo
.RecordsetClone.Bookmark = .Bookmark
Select Case strDirection
    Case "Quit"
        DoCmd.Close acForm, "SampleInfo", acSaveNo
    Case "Next"
        .RecordsetClone.MoveNext
        If Not .RecordsetClone.EOF Then
            DoCmd.GoToRecord acForm, "SampleInfo", acNext
        Else
            .RecordsetClone.MoveLast
            MsgBox "Last record."
            .btnNext.Enabled = False
        End If
        .btnPrevious.Enabled = True
    Case "Previous"
        .RecordsetClone.MovePrevious
        If Not .RecordsetClone.BOF Then
            DoCmd.GoToRecord acForm, "SampleInfo", acPrevious
        Else
            .RecordsetClone.MoveFirst
            MsgBox "First record."
            .btnPrevious.Enabled = False
        End If
        .btnNext.Enabled = True
End Select
End With
End Sub
 
Last edited:
The problem is that the form is in Edit Mode when you press the button.
You can test the above statement by adding the below code:
Code:
Private Sub cmdNext_Click()
'On Error GoTo Err_Handler:
 If Me.Dirty Then
  Me.Undo
 End If
 DoCmd.GoToRecord , , acNext
..

That´s is weird... before adding the cmdSave button those nav buttons were working perfectly fine.

But the fix suggested worked and I will just add the boundaries to avoid the error raised when reached first/last record.

Thanks!
 
Login form keeps telling me Diogo already logged in.

Test if form is on first or last record before moving. Here's how I handle custom navigation buttons:

...

This solution of yours is very similar to the "Access 2002 Desktop Developer´s Handbook" by Litwin, Getz and Gunderloy... ;)

In fact I decided to use their fSubNavigation form that can be used throughout the forms and takes less time to adapt.

Once I finish this project I will post the code here.

Appreciate the help!
 
Login form keeps telling me Diogo already logged in.

Hi diogo
I see you are using my password login form code from https://www.access-programmers.co.uk/forums/showthread.php?t=193131
That includes a security feature that prevents the same user logging in on multiple PCs. As you have several logins where you haven't logged out, nobody responding on another PC can login!

for the benefit of other members, to fix that it is necessary to delete all records in tblLoginSessions with no data in the LogoutEvent field. However it shouldn't prevent repeated login from the same PC... though in your app that's also blocked

Anyway, I've done that, logged in and added a user, clicked Save & no errors occurred
However clicking any other button on the main form is locking the database completely. Whilst I can open frmObservers & frmCardObservation from the navigation pane, I can't do so from the main form.
I'd recommend you use VBA for all code events rather than embedded macros but even after replacing it on the Observers button, the form still doesn't open. It may be because you have 10 events at form level which is a lot - perhaps these are conflicting with each other - otherwise your form may be corrupted

UPDATE
I've now managed to open form frmCardObservation successfully from frmMain though not sure why its now OK
 

Attachments

  • Capture.PNG
    Capture.PNG
    17 KB · Views: 118
Sorry - personally I find you code a little "to messy", where it is jumping here and there and back again, trigger some of the build in events like the Current event.
You need to find out where you code trigger the Edit command/statement, then it can't be right that the form start up in Edit mode, then why do you then have a Edit button if the form always is in Edit mode?
 
Hi diogo
...
UPDATE
I've now managed to open form frmCardObservation successfully from frmMain though not sure why its now OK


Hi, Colin.

I had no issues when opening it here and from another computer in my company.

But I will run more tests on it and review.

Thanks!
 
Sorry - personally I find you code a little "to messy", where it is jumping here and there and back again, trigger some of the build in events like the Current event.
You need to find out where you code trigger the Edit command/statement, then it can't be right that the form start up in Edit mode, then why do you then have a Edit button if the form always is in Edit mode?

Not sure what you mean by messy, but since it is my first project I am sure it would not be perfect. I see what you mean by "jumping here and there and back again", I am still trying to figure out where I should place the code inside the events, it is a long lerning curve... :D Any insight is more than welcome, JHB.

The form is not meant to open in edit mode, it is supposed to open and lock all fields except the cboGoTo controls and a couple of buttons. If the user decides to change something he can hit the cmdEdit which unlocks all controls on the form and disable some buttons.

But since that first 2105 appeared it never worked again, so I guess I did somehting wrong on the code.

At this point I decided to start over on a clean file and so far it is working fine...
 
Hi diogo
...
I'd recommend you use VBA for all code events rather than embedded macros but even after replacing it on the Observers button, the form still doesn't open. It may be because you have 10 events at form level which is a lot - perhaps these are conflicting with each other - otherwise your form may be corrupted

How many events do you think would be reasonable?

Maybe I can spread that code trhoughout other things like constraints at table-level and conditional formatting?
 
How many events do you think would be reasonable?

How long is a piece of string?
Personally I use as little code as possible at form level
Typically Open/Load/Current and if appropriate Timer
I occasionally use others such as Activate/GotFocus/LostFocus but rarely do I have more than 5 or so form events - NEVER 10

As I said there is a risk of multiple events either conflicting with each other or at the very least repeating other code causing delays and loops

Maybe I can spread that code throughout other things like constraints at table-level and conditional formatting?

Possibly - I would first check whether you actually need all of the code
 
"Error 2105: You Can´t Go to the Specified Record" on a the navigation buttons:Next, Previous, First and Last.

I see this behavior when I make my own "Next, Previous and Last" buttons. Just for giggles, I checked your code to see if its complied it was not. Usually that fixes "My issues".

Also you have
Code:
Option Compare Database
Option Explicit
on all code except frmCardObservation
 
How long is a piece of string?
...

I guess it returns a LONG... that´s is big!

...
Personally I use as little code as possible at form level
Typically Open/Load/Current and if appropriate Timer
I occasionally use others such as Activate/GotFocus/LostFocus but rarely do I have more than 5 or so form events - NEVER 10
...

I decided to go back to the book I am using to make the fSubNavigation and I realized I made a terrible mistake on the Form_Current event. So I can remove the large part of that code from my main form_current event and move it to the fSubNavigation form.

I will probably end up with:
1. OnCurrent (Less code than it was originally posted)
2. KeyDown
3. OnDirty
4. OnUndo

Quention and possibly a dumb one: when you say you don´t have more than 5 events at form-level, you are excluding the control´s events, right?

...
Possibly - I would first check whether you actually need all of the code

For sure, I am revising it already and what you guys said indeed makes a lot of sense to me.

Thanks for the help!
 
...Just for giggles, I checked your code to see if its complied it was not. Usually that fixes "My issues".

Also you have
Code:
Option Compare Database
Option Explicit
on all code except frmCardObservation

AccessBlaster What is a complied code? How can I check it?

I fixed the Options on that form, thanks!
 
AccessBlaster What is a complied code? How can I check it?

I fixed the Options on that form, thanks!
Here is a snapshot of your code, with the compile option "not grayed out". Sometimes this will fix the small gremlins that plague my code. Good luck, with your project.

attachment.php
 

Attachments

  • compile.JPG
    compile.JPG
    97.7 KB · Views: 277

Users who are viewing this thread

Back
Top Bottom