Results 1 to 15 of 15
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stopping GoTo Next Record (Access 2000)

    Is there a way to stop the user from going to the next record via the mouse wheel or any other method? Basically, I would like the ability to disable going to the next record on most of my forms.

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Stopping GoTo Next Record (Access 2000)

    Do you have the Cycle property for the form set to CurrentRecord? That's the first thing to do if you don't want the cursor to automatically jump to the next record when it exits the last control in the tab order. However, that doesn't stop the PageUp, PageDown, scrollwheel from moving the record pointer. Actually the simplest way to disable that ability is to only load a single record at a time, either by changing the form's recordsource or by setting its filter property. When there is only one record available, it is impossible for the user to use buttons, mousewheels or tabbing to get to another record. Please note, though, that loading a single record at a time is imcompatible with any need the users might have to "browse" the information in the recordset.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    OK. The problem still occurs though when I am entering a new record. Any Ideas on that? Is there a way to disable the mousewheel, page up and page down keys?

    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Stopping GoTo Next Record (Access 2000)

    Sorry, but you'll have to be more specific. Enter a new record under what conditions? And which problem, tabbing out of the record, page up and down, or what? Access 2002 actually recognized a mousewheel event but no such event is available on forms in 2000, so if that's what you're looking for it is problematic. There is code out there (and here in the Lounge) to try to manage scrollwheel events, but without the search feature, it's hard to relocate them. There are other ways of getting around the problem but you need to tell us what kind of form you're dealing with (single or continuous, subform, etc.) and the exact situation you're trying to handle. There isn't any switch you can turn off to prevent this, it takes effort and probably some code.
    Charlotte

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    It is not all that difficult to trap the PgUp and PgDn keys, but to trap the mouse wheel in versions before Access 2002 requires complicated code involving Windows API functions.

    If you want to completely prevent the user from moving to another record, the easiest way is probably to use an unbound form, i.e. the record source of the form and the control source of the controls is empty. You would need to have a "Save Record" button that saves the values entered into the text boxes etc. to a table.

  6. #6
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    HI thanks for the input.

    Currently, my form in a single form, but it also contains a subform within it, which is set to be a continues form. My form is also bound to a table. Basically the form is used to record an invoice. If any prior messages could be found regarding the scroll wheel, that would be great. The scroll wheel is more important the pageup/ page down keys because with the scroll wheel, u can change to the next record by mistake. Anyway, it nap time for me. Thanks for the input.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disabling MouseWheel Scrolling (Access 2000)

    Take a look at http://www.worship.co.za/BlackandWhi...MouseWheel.htm for a library that will allow you to handle mouse wheel issues in A2k. That site also contains links to MSKB articles 2783792 (for Access 2000) and 308636 (for Access 97), in case you want to build your own instead of downloading his.
    Charlotte

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Stephen Lebans has a nice solution for the mousewheel problem, which he recently updated. See MouseWheelOnOff. Download MouseWheelHook.zip. It contains a DLL that you must copy to the same folder as your database or to your system folder, and an Access 97 database that demonstrates how to use it. If you want to use this in your own database, import the module modMouseHook from the sample database. This module contains functions MouseWheelON and MouseWheelOFF that you can call from your form.

    To disable PgUp and PgDn on your form, do the following:
    <UL><LI>Set the KeyPreview property of the form to Yes.
    <LI>Create an event handler for the KeyDown event of the form:

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyPageUp, vbKeyPageDown
    KeyCode = 0
    End Select
    End Sub

    <LI>This event handler inspects the key pressed by the user and converts the key code for the page up and page down keys to 0, thereby canceling their action.[/list]HTH

  9. #9
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Excellent, that dll file and your function work perfectly [img]/forums/images/smilies/smile.gif[/img]

    Thanks

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Hans,

    Here's me again trying to make things awkward.

    Is it possible to use the PgUp & PgDn keys, but stop them from going beyond the 1st and last records?
    Cheers,
    Andy

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    PgUp doesn't even try to go beyond the first record.
    If you want to prevent PgDn from going to a new blank record, set the AllowAdditions property of the form to False.

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Hans,

    You are absolutely correct with respect to the first record. I'll get back to you tomorrow with a scaled down copy of what it is I think I'm trying to do.
    Thanks again for following up,
    Cheers,
    Andy

  13. #13
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Hans,

    I've attached a scaled-down database demonstrating variations on record movements and some of the anomalies that I've run into. I realize that you wouldn't necessarily use all of these combinations in one form, but it's easier to test them all together.

    Ok, here's the sequence of events:

    1. Open EOF_Test.mdb

    2. Press Ctl-End: It goes to last record correctly

    3. Press Ctl-Home: You have to do this twice to go to first record
    Cheers,
    Andy

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    I don't know why you have to press Ctrl+Home twice.

    You can test whether you are on the first record:

    If KeyCode = vbKeyF9 Then
    If Me.CurrentRecord > 1 Then
    DoCmd.GoToRecord , , acPrevious
    KeyCode = 0
    End If
    End If

    and on the last record:

    If KeyCode = vbKeyF10 Then
    If Me.CurrentRecord < Me.RecordsetClone.RecordCount Then
    DoCmd.GoToRecord , , acNext
    KeyCode = 0
    End If
    End If

  15. #15
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping GoTo Next Record (Access 2000)

    Hans,

    Sorry for the delay in responding. Needless to say all worked as usual once you've put your magic touch to things. The Ctrl-Home thing works as well, so I'm not sure what was happening. It was probably because I hadn't had my 2nd coffee yet.

    Anyway, thanks again
    Cheers,
    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •