Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Dec 2000
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Programmatically Updating Control? (Access 2000/VBA)

    I have a text box control that may or may not be entered from the keyboard. In other words, the user may not enter any data. I wish to programmatically simulate an update to the control and therefore go through the After Update Event.

    I know this must be easy, but I am a novice at VBA. Does anyone have any suggestions? TIA.

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

    Re: Programmatically Updating Control? (Access 2000/VBA)

    You can call the AfterUpdate event procedure just as you would call any other event procedure in the module, but a better way to handle that is to put whatever code you're running in the AfterUpdate event in a private sub in the form's module and then call that sub from the AfterUpdate event of the control and also from wherever else you need it.

    You have to decide *when* you want to call that routine if the user never enters the control or doesn't change the value in it, though. One logical place would be in the BeforeUpdate event of the form, but that doesn't happen unless the record becomes dirty.

    What exactly are you trying to accomplish with this? There may be some other suggestions if we knew more about what you want to do.
    Charlotte

  3. #3
    Lounger
    Join Date
    Dec 2000
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Programmatically Updating Control? (Access 2000/VBA)

    Charlotte:

    Thanks for the reply. I realize that I did not go into a lot of detail in my original post.

    I've actually solved the immediate problem that prompted my post but I have a more general question. Please allow me to explain the background of this project: The client has engaged us to redevelop an old DOS application in Access VBA. The old application uses the enter key to jump from field to field and he wants to retain the same functionality. I know that everyone must be asking "Why?" but I'm certain it has to do with minimizing the staff retraining effort when the new system goes in. In any event, the approach we've taken so far (We're still at the beginning of development so it's not too late to change this approach) is to test, in the KeyPress routine for each control, for KeyAscii = 13 (enter). If it = 13, we do a SendKeys "{TAB}" to emulate a tab key being pressed. "Klugy", yes, but it does work.

    Here's the general question: Does anyone have a more elegant way of coding this?

    TIA.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Programmatically Updating Control? (Access 2000/VBA)

    I'm a bit puzzled - I believe the default setting under Tools/Options/Keyboard is to move to the next field when the enter key is pressed. You can change it to go to the next record or to not move at all. We use that default setting with people who were trained to use the ENTER key on old legacy systems. Did I miss something here that is requiring you to convert the ENTER key to a TAB key?
    Wendell

  5. #5
    Lounger
    Join Date
    Dec 2000
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Programmatically Updating Control? (Access 2000/VBA)

    Thanks for the reply.

    We are VBA novices and had initally changed this option to "Don't Move" not realizing that keeping it at "Next field" was exactly what we wanted! The code we've developed to date is predicated on it being "Don't Move". However, we may end up reworking the app so that we can change it back to "Next field".

    Thanks.

Posting Permissions

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