Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cursor movement in a datasheet form (A97/SR2)

    Would like to make the cursor movement in a continuous form be similar to that as in a datasheet. Have had
    partial success in accomplishing this. To make the up and down arrow keys function between records, the following event procedure was put in the OnKeyDown Event for the form:

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyDown
    DoCmd.GoToRecord , , acNext
    Case vbKeyUp
    DoCmd.GoToRecord , , acPrevious
    End Select
    End Sub

    My continuous form has several fields, one of which is a text field that may have 2 or more rows of text
    displayed. The settings for: (Tools); (Options); (Keyboard); (Behavior Entering Field); is: (Go to End of
    Field). What I would like to achieve is: When entering the field with multiple rows of text, I would like the up
    arrow key to move the cursor up one row at a time until it gets to the first row of text. After the cursor is in the
    top row of text, then the next up arrow press would move the cursor to the previous record. I am at a loss on how
    to program this. Help would be greatly appreciated.

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

    Re: Cursor movement in a datasheet form (A97/SR2)

    You're trying to make the arrow keys behave in two different ways at once. How is the code supposed to be able to determine how many rows of text are visible in the control? If you can figure that out, it would be a start, but remember that the form can only deal with the current record. If one record has multiple rows of text but the previous didn't, you would have to test for the length of the text in the control and then switch the arrow key functionality around. Then you would have to determine when you were on the *last* row of text and switch the functionality back. This seems like an awful lot of work for not much payoff.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor movement in a datasheet form (A97/SR2)

    Is there any way to get into the inner workings of the system and figure out how Microsoft made it happen? What I am trying to accomplish is to duplicate the default cursor movement that occurs in datasheet view. 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: Cursor movement in a datasheet form (A97/SR2)

    What default movement? In datasheet view, the arrow keys navigate between fields and records. It looks to me like you've already figured that out. What you're *trying* to do isn't behavior I can duplicate in Access in either a datasheet or a table, so I don't know what you're trying to hack.
    Charlotte

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor movement in a datasheet form (A97/SR2)

    I have attached a small database with two forms - Continuous & Datasheet. The words that I have entered further explain and show what I am trying to achieve.

  6. #6
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor movement in a datasheet form (A97/SR2)

    Reattach attachment
    Attached Files Attached Files

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

    Re: Cursor movement in a datasheet form (A97/SR2)

    OK, you have two different things going on and it wasn't clear from your posts alone. The arrow keys only navigate within the text in your datasheet if you click within the text in a field. Otherwise, they just navigate to the next record.

    I'm not sure what you mean by limiting the user to functions that you provide. You can do that anyhow in Access by creating custom toolbars and suppressing the built-in menubars. If you only make your custom menubars available, then that's all the user can work with. If you get more specific about the kind of thing you want to prevent the user from doing, someone can undoubtedly help you accomplish it.

    Are you assuming that the user will NOT be using a mouse on these forms? That's by far the easiest way to position the insertion point where you want it. The arrow keys are going to be cumbersome no matter what you do with them. Plus, even with a datasheet, you have to click in the field to get the arrow keys to navigate within the field. I don't know of any way to do that except with the mouse. <img src=/S/confused.gif border=0 alt=confused width=15 height=20> If they *are* clicking in the field anyhow, why not just put the insertion point where they want it? If you absolutely *must* use arrow key navigation in the field, use the mousedown event.

    I've attached your file with the continuous form modified to come closer to what you want. The problem you will run into is figuring out when to change the behavior. I declared a module level boolean variable and it gets set to true in the MouseDown event of the control and set to false in the Exit event of the control. The behavior in the KeyDown event only moves between records if the variable is false or if the cursor is at the end of the text. Otherwise, the arrow keys navigate within the text, which is default behavior.
    Attached Files Attached Files
    Charlotte

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cursor movement in a datasheet form (A97/SR2)

    Thanks for your assistance and patience. Quite often what a person is thinking and what they said are not properly communicated or understood by another. It is now closer to what I want. Thank you again for your help.

Posting Permissions

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