Riddle - On Current depends on column (1 Viewer)

spikepl

Eledittingent Beliped
Local time
Today, 14:57
Joined
Nov 3, 2010
Messages
6,142
I have an A2010 form with a MoveUp and MoveDown button. A click will move the last record I clicked on, up or down.

When on new record, both buttons should not be enabled.

If I select a record by clicking in it and I click MoveDown until MoveDown is disabled, I wind up in the last record of data just fine.

Now, MoveUp will be disabled if I click in the new row, first column. But not if i click in any other column of first row. If I hide the first column the same behaviour is now exhibited by the new first column.

I want it disabled, no matter which column of new row is clicked.

When I click in the first column, On Current is fired, and that code disables my button as it should. But if I click in another column, On Current is not fired. Why?

Addition:

- If I click in any but the first column of new row, thereafter clicking in first column does not fire on current.
- If I click in some other row, then I can click in any column of the new row and the current event fires
 

Attachments

  • Riddle-strangecolumnbehaviour.accdb
    984 KB · Views: 56
Last edited:

Pyro

Too busy to comment
Local time
Today, 22:57
Joined
Apr 2, 2009
Messages
126
This line:

Code:
Me.cmdMoveUp.Enabled = Not Me.CurrentRecord = 1 And Not Me.CurrentRecord > Me.Recordset.RecordCount

Evaluate the recordcount first.

Code:
Dim L as long

With Me.RecordSetClone
[INDENT].MoveLast
L = .RecordCount
[/INDENT]
End With

Me.cmdMoveUp.Enabled = Not Me.CurrentRecord = 1 And Not Me.CurrentRecord > L



switch .Recordset to .Recordsetclone
 

Pyro

Too busy to comment
Local time
Today, 22:57
Joined
Apr 2, 2009
Messages
126
Sorry, the line above it has the same issue. My fault for only glancing quickly.
 

Pyro

Too busy to comment
Local time
Today, 22:57
Joined
Apr 2, 2009
Messages
126
See Attached.
 

Attachments

  • Riddle-strangecolumnbehaviour.accdb
    976 KB · Views: 58

spikepl

Eledittingent Beliped
Local time
Today, 14:57
Joined
Nov 3, 2010
Messages
6,142
Was there a change? When I click in new row in some column, MoveUp is still enabled.

Anybody is welcome to chime in.
 

Pyro

Too busy to comment
Local time
Today, 22:57
Joined
Apr 2, 2009
Messages
126
It is working correctly for me in the attachment from my previous post. No matter where i click in the new row, nor which row i am clicking into the new row from, move up is always disabled.

I have attached an AVI recorded in Snagit demonstrating my results.
 

Attachments

  • Test.zip
    282.3 KB · Views: 55

spikepl

Eledittingent Beliped
Local time
Today, 14:57
Joined
Nov 3, 2010
Messages
6,142
MoveUp still not disabled.

1. Open the db
2. Click anywhere in third row from bottom
3. Click MoveDown
4. Click any column but first, in the new (=last) row

MoveUp is still enabled

I have no understanding of what is happening here,which is why I cannot, offhand, fix this!
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 13:57
Joined
Sep 12, 2006
Messages
15,710
Spike: I haven't looked at your attachment, but what does this mean in #2

Me.cmdMoveUp.Enabled = Not Me.CurrentRecord = 1 And Not Me.CurrentRecord > Me.Recordset.RecordCount

I don't use currentrecord, but is it ALWAYS an ordinal with the top record displayed being #1?

if you filter or re-sort the recordset, what happens to the currentrecord counter?

I just wondered if that had anything to do with your issue.
 

spikepl

Eledittingent Beliped
Local time
Today, 14:57
Joined
Nov 3, 2010
Messages
6,142
To solve this: do not muck about with current record set. Apparently even Access got confused and did not know where it was.

Now, wherever I could I changed to Recordsetclone instead. Also, in On Current, need to do Recordsetclone.MoveLast to get proper recordcount.

Now it seems to work. Thanks for all thoughts.

Attached is the working one, with the few changes implemented.
 

Attachments

  • Riddle-strangecolumnbehaviour - solved.accdb
    1 MB · Views: 50

Users who are viewing this thread

Top Bottom