Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Command Order (Access 2002)

    I have written a code for a button that tries to set the focus on a text box, delete its contents, insert a specified number then run a query which uses this number. However, although I have done the set focus, delete and send keys command first and then the open query command, it seems to be running it in reverse order, ie query first, on old info, then adding the new info to the box.
    I would be grateful for any suggestions about how to cure this.

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

    Re: VB Command Order (Access 2002)

    You don't need to set focus to a text box to clear its contents. You can use code such as

    Me.txtSomething = Null

    where txtSomething is the name of the text box. If the text box is bound to a field in the record source of the form, keep in mind that clearing the value of the text box doesn't affect the value of the field in the underlying table until the record has been saved.

  3. #3
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Command Order (Access 2002)

    thank you that sorted it out. But why do you know why my previous code, albeit less elegant than yours, result in things running in the wrong order?

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

    Re: VB Command Order (Access 2002)

    SendKeys simulates using the keyboard. The code doesn't wait until the keystroke has been processed.

Posting Permissions

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