INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Repeating Corrupt code Behavior

Repeating Corrupt code Behavior

(OP)
I have a continuous form that the numlock key toggles on as I tab between records. Sometimes decompiling the file and compiling fixes it but sometimes I have to jigger around in code and compile to get it to behave. This keeps coming up as the form is transferred to new FE's when a FE and BE pair is generated out of a central system based on specific purpose (walking the proprietary/non-proprietary line here).

That said this particular form has a 0 width control on it...

CODE

Private Sub txtTabStop_GotFocus()
    'This visible behind not seen control is needed for the record to receive focus when all data entry controls are disabled with conditional formatting
    'Otherwise the focus jumps to something like the close button in the footer instead of the next record
    
    SendKeys "{TAB}" 'Tab to next enabled control or record
    
End Sub 

The issue to my best recollection started occuring after using the above workaround.

Any thoughts on repeated compiled code issues or alternatives to my Sendkeys?

RE: Repeating Corrupt code Behavior

It's a known issue apparently.. https://support.microsoft.com/en-us/kb/179987

It suggests putting a DoEvents after the SendKeys command to ensure it finishes before another is called.

Or mess about manually keeping the state of the numlock key.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Repeating Corrupt code Behavior

(OP)
D'oh... Search for bugs on the statement you added when things are weird.

Interestingly adding Doevents after the Sendkeys line did not seem to help in this case.

But understanding the source of the problem lead me to use conditional formatting on txtTabStop with logic opposite that which makes the control needed to receive focus.
I'm not saying the bug will never be experienced on the form but it at least it isn't nearly every tab amongst records.

Now that the control can only receive focus on bad records, I can seriously consider just navigating to the next record and possibly avoid sendkeys.

Many thanks. As I like to say, when all else fails go with the obvious.

RE: Repeating Corrupt code Behavior

SendKeys has always been a bit of a blackhat command, and should be avoided where ever possible.

I like their solution, even MS are well .. this might fix it , if not try this, or maybe that lol

i thought it funny that if you implemented the numlock key state option, it might start flashing like a Christmas tree if the SendKeys was looping that often.

I can imagine a lot of support calls from users complaining their keyboard was freaking out and lights were flashing like crazy

I might write a function to toggle that and the capslock and see if I can make the keyboard go into 'Disco' mode afro2

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Repeating Corrupt code Behavior

(OP)
I've avoided Sendkeys for a long time but it seemed right in this case because I wanted it to tab to the next control or record... It looks like I didn't try hard enough to avoid it in this case.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close