Lebans NavButtons

Kiwiman

Registered User
Local time
Today, 07:24
Joined
Apr 27, 2008
Messages
799
Howzit

Has anyone come across this bug when using Lebans Navigaton Buttons?

The frmNavButtons is embedded into another form as a subform. You are on the first record, and you click on the "Add New" navigation Button. This creates a new record, but when you try and navigate away from the new record, by using the "Previous" Button:
  • the first click does nothing
  • you get an error messge saying "No Current Record"

I have tested this on the download I took form his site, and it happens there as well. I thought it may have something to so with my app.

I have uploaded a copy of his db - does anyone have any ideas how to resolve this? I have been playing with this for days, but has got me stumped.

Form to open - frmSampleRecordNavigation
 

Attachments

I do not get an error. Do you have your system set to Break on All Errors instead of UnHandled errors?
 
Howzit

That is pretty bizarre. I get the error every time. I put a stop on the cmdPrevious_Click command, right before the msgbox. For soem reason when I put it at the start, no errors occur.

I'm not sure how to put the break on all errors... How do you do that?
 
Howzit

The second point should read the second click gives me an error message...

Howzit

This creates a new record, but when you try and navigate away from the new record, by using the "Previous" Button:
  • the first click does nothing
  • you get an error messge saying "No Current Record"
 
While looking at the code go to Tools>Options>General Tab.
 
The first click goes to the previous record for me.
 
Howzit

Thanks for that - its set to Break on Unhandled Errors.

Hmm.

If I am not on the first record, say the 8th record (of 65) and add a record, then hit the previous button, I end up on 7th record. Its almost like it is bookmarking the previous record.
 
OK, now I see what you are talking about. I'll do some more testing. To create the first error you need to create a new record abter goint to the new record. Then the symptom you describe happens.
 
The code is in the class module of the frmNavButtons form. Go look at it and you can see why it is doing what it is doing. You can fix it if you like.
 
Howzit

Thanks RG.

A little bit of relief that you are getting a similar bug to me. I have been looking at the class module (it was my initial thought as the other code is pretty straight forward - he says), but I just can't figure it out. Not sure if it is do with the synchronisation bit or where it sets the txtPos value. But probably somewhere completely different.

I've been battling it for days but can't for the life of me work it out. Normally I would have some idea to get around it (maybe not the most elegant way, but it works), especially after days of not getting anywhere, but when it comes to class modules...Unfortunately there are no lights on here.
 
I've almost got it. I'll let you know when I'm done.
 
Howzit

RG did you have any luck with this? I came up with this that seems to work, but still testing. I put the change in the cmdPrevious button event

I was wondering if you had any alternative?

Code:
Private Sub cmdPrevious_Click()
    On Error GoTo Err_cmdPrevious_Click

    Dim varBookmark As Variant
    'Stop


    With NavForm
        ' Store bookmark in case the Move doesn't work.
        varBookmark = .Bookmark
        If .NewRecord Then
            .Recordset.MoveLast
        ElseIf .CurrentRecord > 1 Then
            'Move back one record from the stored bookmark
            .Recordset.Move -1, varBookmark
            '.Recordset.MovePrevious
        End If
    End With


Exit_cmdPrevious_Click:
    Exit Sub

Err_cmdPrevious_Click:
    ' In case of a No Crurrent Record error, move to the first then the last record
    If Err.Number = 3021 Then
        With NavForm
            .Recordset.MoveFirst
            .Recordset.MoveLast
        End With
    Else

        MsgBox Err.Description & " " & NavForm.CurrentRecord
        Resume Exit_cmdPrevious_Click
    End If
End Sub
 
I did not come up with anything better than what you have. Good work.
 
Howzit

RG - thanks for looking at this anyway. Appreciated.
 

Users who are viewing this thread

Back
Top Bottom