Current Record

burrina

Registered User.
Local time
Today, 10:22
Joined
May 10, 2014
Messages
972
I have a form with tabs on it. Form some reason my code does not work until I use my find combobox to search, then it works? Example below, that code would normally disable the back button,i.e. previous record if you were already on the first record. It shows disabled , like I say until I search for another record?
No other interfering code and it's on the OncurrentEvent !

PHP:
   'Record Selector Code.
If Me.CurrentRecord = 1 Then
        Me.cmdback.Enabled = False
        Me.cmdfirst.Enabled = False
    Else
        Me.cmdback.Enabled = True
        Me.cmdfirst.Enabled = True
    End If

Solution:
PHP:
    Dim rst As DAO.Recordset
    Dim lngCount As Long
 
    Set rst = Me.RecordsetClone
 
    With rst
        .MoveFirst
        .MoveLast
        lngCount = .RecordCount
    End With
 
Last edited:
I struggled a bit to understand your post but got there in the end, and your supposed solution wasn't clear either, i.e. where do you call/run it?

So in attempt to understand your proposed solution, are you running that code in the Current event too?
 
Sorry for the confusion, Yes all of it runs on the current event for ALL of the command buttons, not just what I posted. By declaring it, it now works as designed.

Thanks,
 
Ok, but it's not efficient running the movelast/first methods in the current event. If CurrentRecord isn't working for you (which it should), you could probably do one of the following:

Code:
If Me.RecordsetClone.CurrentRecord = 1 Then

Code:
On Error GoTo ErrorHandler

    rst.MovePrevious
    Me.cmdback.Enabled = True
    Me.cmdfirst.Enabled = True

Exit_ErrorHandler:
    Exit Sub

ErrorHandler:
    Me.cmdback.Enabled = False 
    Me.cmdfirst.Enabled = False
    Err.Clear
    Resume Exit_ErrorHandler
 

Users who are viewing this thread

Back
Top Bottom