469,315 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

How to Clear the Debug Window

43
Is there any good way to use VBA to clear the Immediate Window? I found this answer but it only clears down to the current cursor position. Any way to place the cursor at the end of the window and execute this code?

Thanks!

Expand|Select|Wrap|Line Numbers
  1. Debug.Print String(256, vbCrLf)
  2.  
Oct 12 '11 #1

✓ answered by ADezii

@NeoPa:
Actually
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdDebugWindow
  2.  
  3. SendKeys "^a"
  4.  
Will Select the entire contents of the Debug Window

Finalized Code:
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.RunCommand(acCmdDebugWindow)
  2. SendKeys ("^a{BS}")

9 22780
ADezii
8,800 Expert 8TB
  1. Make sure the Debug Window is Open and has the Focus
  2. Send the Cursor to the End of the Debug Window
  3. Execute your CrLfs
  4. Send the Cursor back to the ULC of the Debug Window
    Expand|Select|Wrap|Line Numbers
    1. DoCmd.RunCommand acCmdDebugWindow
    2.  
    3. SendKeys "^{END}", True
    4.  
    5. Debug.Print String(256, vbCrLf)
    6.  
    7. SendKeys "^{HOME}"
    8.  
Oct 12 '11 #2
NeoPa
32,173 Expert Mod 16PB
Nice work ADezii :-) I didn't expect that to be workable, but it was. Here's another version that deletes the text rather than scrolling it off :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.RunCommand(acCmdDebugWindow)
  2. SendKeys("^{HOME}^+{END} {BS}")
I tried using ^A (Select entire contents) but that didn't work with SendKeys() (although it does from the keyboard of course).
Oct 12 '11 #3
ADezii
8,800 Expert 8TB
  1. Strictly out of curiosity, NeoPa, what made you think that it wouldn't work?
  2. Nice, condensed, more efficient, Version of my Code to Clear the Debug Window.
  3. Does the {BS} stand for Backspace or something different? (LOL)
Oct 12 '11 #4
ADezii
8,800 Expert 8TB
@NeoPa:
Actually
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdDebugWindow
  2.  
  3. SendKeys "^a"
  4.  
Will Select the entire contents of the Debug Window

Finalized Code:
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.RunCommand(acCmdDebugWindow)
  2. SendKeys ("^a{BS}")
Oct 12 '11 #5
Sedrick
43
Thanks! I didn't know SendKeys even existed! There must be something different about Access 97 though. I can't get it to do the Control Sequences. If I do SendKeys "
Expand|Select|Wrap|Line Numbers
  1. SendKeys ("^a{BS}")
  2.  
It just puts the backspace mneumonic - "BS" - at the cursor position.

Not a problem though. My original intent was to let the user see what was printed in the window. But I recalled that I was collecting the information anyway and could just do it in a regular form.
Oct 12 '11 #6
ADezii
8,800 Expert 8TB
You must enclose BS in Braces ({...}):
Expand|Select|Wrap|Line Numbers
  1. SendKeys ("^a{BS}")
Oct 12 '11 #7
NeoPa
32,173 Expert Mod 16PB
ADezii:
Strictly out of curiosity, NeoPa, what made you think that it wouldn't work?
Interesting. When I tested with "^A", as indicated by the example in the Help, it failed. Now I've tested with "^a", your version, it works fine.

ADezii:
Nice, condensed, more efficient, Version of my Code to Clear the Debug Window.
Thank you. I appreciate praise from another experienced coder.
ADezii:
Does the {BS} stand for Backspace or something different? (LOL)
If you check the Help page though, you'll see a whole lot of special codes in braces ({}) that you can work with. I tried using "{DEL}" and that didn't seem to work either (though it should have done according to the Help page) :-(
Oct 12 '11 #8
ADezii
8,800 Expert 8TB
NeoPa:
I tried using "{DEL}" and that didn't seem to work either
Expand|Select|Wrap|Line Numbers
  1. 'Will work just as well
  2. Call DoCmd.RunCommand(acCmdDebugWindow)
  3. SendKeys ("^a{DEL}")
Oct 12 '11 #9
NeoPa
32,173 Expert Mod 16PB
Well, this is just BACKSPACE! I just tried that again exactly as you had it and, what do you know, it worked fine. It seems I just need to explain what I tested before that failed, for you to find that it works after all. It's been fun testing though :-)
Oct 13 '11 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Thomas Anderson | last post: by
3 posts views Thread by Mike Turco | last post: by
7 posts views Thread by Thomas Pecha | last post: by
1 post views Thread by Adrian Constantinescu | last post: by
9 posts views Thread by Bob | last post: by
2 posts views Thread by Bob | last post: by
1 post views Thread by JPS | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.