why in the code window does the cursor now move on its own

This has happened once before in another database and I erased it to solve the problem and it was with an earlier version.
In the vba code window of Access, when I try to edit text, if I open up a line of code the text will turn red and then may close the gap on its own and if I try to type some text it may rearrange this by a character or two. It almost sounds like a virus attack but I do not think so. I just think it is something that just got out of wack somewhere with the intellisence. This is almost hard to describe what is happening, but if it happened to you, you would know just what I am talking about
HELP
cazinkAsked:
Who is Participating?
 
harfangCommented:
Well, that is the solution, I believe.

If any VB code is running while you try to edit a module, you will experience what you saw (immediate syntax correction while you type, which makes it nearly impossible to edit any code at all). An open form with a timer event is one way to have VB code execute repeatedly, but there are a few others. If you don't want this behaviour (and who would?), make sure no part of your project is running.

Normally, you can indeed edit the code behind a form while it's open (and it's a useful debugging tool as well), except if you have an active timer event, in the same form or in another. The risk of corruption is higher when you have several instances of the same class module, but that is a rare technique for forms. What I'm saying is that most developers do debug live forms all the time, although this can cause problems in some special cases, among which the one you describe.

Does that answer your question better?
(°v°)
0
 
omgangIT ManagerCommented:
Can you post a screen shot of the VBE with the red text please?

OM Gang
0
 
cazinkAuthor Commented:
Not really it is intermittent now. In the past when this started it was peculiar to a certain database and got worse as time when on. Lets say I have this line of text Me.txtTextBox and I want to change the code and I have renamed the control name. When I place the cursor in the line at the period and hit the space bar the line now looks like this
Me. txtTextBox then the letters turn red as if an error had occurred and if I delete back to the period and start to type the letters might rearrange in the first position after the period. Something triggered this and it becomes impossible to do any amount of coding without making mistakes.  
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
omgangIT ManagerCommented:
I've never experienced anything like you describe.  The VBE default setting for syntax errors is to highlight to code in red text but this doesn't sound like what you're describing.

OM Gang
0
 
harfangCommented:
Ah, yes, a fun one.

Steps to reproduce this behaviour: create a new form, set the timer interval to 100, create a timer event (with just "DoEvents" for example), and open the form.

Now, VB will be running some code 10 times every second. In order to do that, it will attempt to compile any code in an unknown state. As a side effect, this will terminate the editing of any line, with the usual clean-up: removal of spaces, highlighting of syntax errors, etc. It becomes very weird to try editing VB code.

Annoying... but on the other hand, it's very bad practice to edit your VB code in a live database (if you edit live class modules, you easily run into VB corruption, for example). So you should simply change your habits: create and edit VB code with all objects closed or in design view. Just like with compilable languages.

Cheers!
(°v°)
0
 
cazinkAuthor Commented:
I am not quite sure if your comment is a solution or a way to recreate the same thing happening.
I have been known to edit code while the form is active and not in design mode. Did not realize this is a problem
Will not do this in the future. Is there a solution?
0
 
cazinkAuthor Commented:
Not really,
In other words, since I do not have any forms with timer events or timer intervals set or running, then this was not the culprit and it may have been just editing an open form. But to your solution, I did not follow the method of recreating the symptom. An exclamation with a little more detail would be better, since I did not understand where you were going with your example.
Regards,
Charly
0
 
harfangCommented:
If it wasn't a form with a timer event, then this is becoming complicated.

I know that the symptoms you describe are caused by some VB code running. As I tried to explain, VB is continuously checking the syntax to compile the very module you are editing. Normally, you get a syntax check when you leave a line (the highlighting in red), a compilation or pre-compilation when you request it or when you try to run a given function, and then run-time errors. In this "running" mode, you get a continuous syntax check and attempts at compilation.

Since VB is multi-threaded (it isn't as a language, but it is through the event handling of Access), you can have code running in one module while another is open for editing.

The complicated question is then: what portion of your code is running? I have no means of answering that, of course; a timer event was my best bet. It could be a loop, perhaps some quite long operation, with a "DoEvents" here and there. The loop will continue to execute, but without locking the application. At every "DoEvents", all user input would be processed, including the editing of VB code. But then the loop would resume, forcing VB to maximize the compile state of the project, hence the syntax check.

If code is running, you should experience some flicker. The title bar of the VB window should flash "[running]", for example. If you want to stop all code in all modules, you can use the square "reset" button. This doesn't stop timer events (or any other events) to fire, but it stops all the rest and releases all class modules. Can you try that the next time you see the symptoms?

Incidentally, I did show a method to recreate the symptoms, not only for omgang but also for you to see that this can be turned on and off, provided you can identify the code that is running, of course.

(°v°)
0
 
omgangIT ManagerCommented:
harfang, thanks for the detailed information.  As I mentioned, I've never seen this behavior before but it makes sense.

OM Gang
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.