Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Records will only scroll down 1

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
US

I have received a request from one of my 'endusers' of my Access application; they want to be able to scroll up and down in the PROSLOG number (primary key, indexed).

I built a macro that contains two events; GoToRecord - Previous, and GoToRecord - Next. I assigned these to the "On Key Down" and "On Key Up". It only works for scrolling down the records. Why?

What do I need to change/code/implement that will allow the endusers use the UP and DOWN Arrows to scroll through the records?

 
I think seeing the code could be something that might trigger off some sparks of recognition on our behalf ...

... just wondering, what do you mean "On Key Down" and "On Key Up" and Macro (we don't use macros, do we)?

You should probably do the testing in the forms key down event, and differensiate behaviour based on the KeyCode - oh, and do have the forms Key Preview property set to yes

[tt]if keycode = vbkeyup then
if me.currentrecord = 1 then
msgbox "alredy at the first..."
else
docmd.gotorecord,,acprevious
end if
end if

if keycode = vbkeydown then
if me.currentrecord >= me.recordsetclone.recordcount then
msgbox "alredy at last ..."
else
docmd.gotorecord,,acnext
end if
end if[/tt]

- but are you sure you want to use this, I mean, the arrowkeys do have their functionality, and removing that in order to have this browsing ...

Roy-Vidar
 

So, you are saying that using the above code will disable my arrow keys -- within this database? No. That wouldn't be a good idea.

Oh, and I use macros because I'm not an Access VBA programmer. I try to digest the code that is give to me, but I couldn't write anything from scratch. Macros give me the ability to manipulate the forms. Without them, I wouldn't have the functionality in my databases.

When you go into the 'Property' sheet of the control or form, they have the 'On key down' and 'On key up' properties/events. I assumed that it meant the 'arrow up' and 'arrow down' keys. I tried the macro out and it scrolls "down" or "back" to the previous records. The problem is that the 'On key up' event will not scroll UP (back or previous) to the previous records.
 
No - but within this form.

There are so many limitations on macros, that you should rather learn VBA - which will prove better - trust me on that ;-) here's a couple of discussions where macros vs vba is discussed thread181-1043254, thread705-882255 ...

The "on key down" event is triggered when a key on the keyboard is "on it's way down". The "on key up" event is triggered when a key on the keyoboard (it might be the same key ...) is "on it's way up" again. It does not relate to any particular key, so that you need to test (test which key is pressed, then determine what action to take based on that) - for instance within the on key down event of controls or the form, as in my sample ... I don't use macros, so I really don't know, but I don't think you can perform such tests with a macro.

Roy-Vidar
 

RoyVidar,

I went back and deleted the references to the On Key Up and On Key Down. Any key that I pressed activated this, so I deleted the macro also.

So, how can I STAY in the PRSLOG field and 'scroll' (by using the ARROW keys) up or down -- effectively moving from record to record?
 
Try using the code in the on key down event procedure of the PRSLOG control?

Roy-Vidar
 

Thanks Roy!

It works as advertised...however...

I switched the vbkeydown and vbkeyup actions. It just seemed more 'natural' for the endusers. I also put in a special 'message' for the msgbox action :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top