CRASH! WTH! :(.......... [me.CurrentRecord] (1 Viewer)

Kaloyanides

New member
Local time
Today, 10:43
Joined
Jan 28, 2015
Messages
11
This is causing my database to crash... I don't have any missing references...

Any ideas? Thx so much in advance...

So simple...? I don't understand... I can't find any help on this one.

If Me.CurrentRecord = 1 Then
Me.cmdBack.Enabled = False
Me.cmdFirst.Enabled = False
Else
Me.cmdBack.Enabled = True
Me.cmdFirst.Enabled = True
End If
If Me.CurrentRecord = Me.Recordset.RecordCount Then
Me.cmdLast.Enabled = False
Else
Me.cmdLast.Enabled = True
End If
If Me.CurrentRecord >= Me.Recordset.RecordCount Then
Me.cmdNext.Enabled = False
Else
Me.cmdNext.Enabled = True
End If
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:43
Joined
Feb 28, 2001
Messages
26,999
Rather than use Me.CurrentRecord, use something like Me.Recordset.EOF or ...BOF to decide if you are at the front or back of the recordset. Easier tests. However, if you have ordinary navigation controls enabled, the controls within the navigation bar do this anyway. Therefore I assume you have a reason for reinventing the wheel.

Offhand, I don't see a syntax error though you probably should use code tags when posting code sequences involve IF/THEN/ELSE/ENDIF blocks. Since it doesn't appear to be syntax, it has to be a run-time error of some sort. I would put a breakpoint on that first IF statement and examine the values of Me.CurrentRecord and Me.Recordset.RecordCount to verify that they are well-defined.

Another possibility comes to mind. Can you do a Compact & Repair on the DB? (If trying to do so, always make a copy first in case the C&R goes bonkers on you.) This behavior COULD be caused by corruption, which is not unheard of. If a simple C&R doesn't help, a DECOMPILE might clean up corrupted code. Here's how you do that.


As a final thought, if Access crashes then you should see a system event log describing the crash. Might be able to get an error code out of it. But I wouldn't bother trying to find it until AFTER you do the C&R and a decompile but the problem persists.
 

Minty

AWF VIP
Local time
Today, 14:43
Joined
Jul 26, 2013
Messages
10,354
What event is this on? The forms Current event?
 

Kaloyanides

New member
Local time
Today, 10:43
Joined
Jan 28, 2015
Messages
11
I use in a couple places...

The one that's causing an issue is below. The Form_Current event.

This one works okay. The Mouse_Wheel event.

Mouse Wheel

On Error Resume Next
If Not Me.Dirty Then
If (COUNT < 0) And (Me.CurrentRecord > 1) Then
DoCmd.GoToRecord , , acPrevious
ElseIf (COUNT > 0) And (Me.CurrentRecord <= Me.Recordset.RecordCount) Then
DoCmd.GoToRecord , , acNext
End If
Else
MsgBox "The record has changed. Save the current record before moving to another record."
End If


This one does not work. The Form_Current event to enable navigation buttons. These features have been in this database for over a decade without an issue. Now, If I uncomment the follow code, the database crashes and does an automatic backup.

Seems so simple..

' If Me.CurrentRecord = 1 Then
' Me.cmdBack.Enabled = False
' Me.cmdFirst.Enabled = False
' Else
' Me.cmdBack.Enabled = True
' Me.cmdFirst.Enabled = True
' End If
' If Me.CurrentRecord = Me.Recordset.RecordCount Then
' Me.cmdLast.Enabled = False
' Else
' Me.cmdLast.Enabled = True
' End If
' If Me.CurrentRecord >= Me.Recordset.RecordCount Then
' Me.cmdNext.Enabled = False
' Else
' Me.cmdNext.Enabled = True
' End If
 

Kaloyanides

New member
Local time
Today, 10:43
Joined
Jan 28, 2015
Messages
11
I just added some ('s and )'s () and it seems to be working...

Can it really be that simple....?

If (Me.CurrentRecord = 1) Then
Me.cmdBack.Enabled = False
Me.cmdFirst.Enabled = False
Else
Me.cmdBack.Enabled = True
Me.cmdFirst.Enabled = True
End If

If (Me.CurrentRecord = Me.Recordset.RecordCount) Then
Me.cmdLast.Enabled = False
Else
Me.cmdLast.Enabled = True
End If

If (Me.CurrentRecord >= Me.Recordset.RecordCount) Then
Me.cmdNext.Enabled = False
Else
Me.cmdNext.Enabled = True
End If
 

cheekybuddha

AWF VIP
Local time
Today, 14:43
Joined
Jul 21, 2014
Messages
2,237
Check your Access version. There has been a recent update that appears to be causing this kind of havoc in otherwise fine db's.
 

Kaloyanides

New member
Local time
Today, 10:43
Joined
Jan 28, 2015
Messages
11
Hate Microsoft.... Love Access but hate Microsoft....

I just went without BUSINESS email for over a month because of Office 365... They could have cared less... I eventually switched hosting companies and now use SiteGround's proprietary email service...

They need to stop breaking shit. They need to stop reinventing the wheel. Sorry, I'm in a mood today...
 

Kaloyanides

New member
Local time
Today, 10:43
Joined
Jan 28, 2015
Messages
11
Surprise surprise...

2022-05-12_08-20-28.jpg
 

isladogs

MVP / VIP
Local time
Today, 14:43
Joined
Jan 14, 2017
Messages
18,186
Version 2204 build 15128.20224 is now available (as of yesterday)
 

moke123

AWF VIP
Local time
Today, 10:43
Joined
Jan 11, 2013
Messages
3,849
A fellow Ma$$hole I see. I'm on the other end of the state.

Code:
If Me.CurrentRecord = Me.Recordset.RecordCount Then

Another way to do this test is with the forms recordset.absoluteposition.

Code:
Sub m_objbtoNext_Click()

    Select Case b_CycleRecs

    Case True

        If frm.Recordset.RecordCount = frm.Recordset.AbsolutePosition + 1 Then
            frm.Recordset.MoveFirst
        Else
            frm.Recordset.MoveNext
        End If

    Case False
        If frm.Recordset.RecordCount = frm.Recordset.AbsolutePosition + 1 Then
            MsgBox "No Next Record"
        Else
            frm.Recordset.MoveNext
        End If

    End Select

    DoEvents
End Sub

The example form is set to cycle the records if you try and move next past the last record or move previous past the first record, but you can set the cycleRecs to false for a message box.
 

Attachments

  • NavBarClassV3.zip
    44.1 KB · Views: 132

Users who are viewing this thread

Top Bottom