Why is my VBA for MS Access Buggy?
Asked Answered
P

1

8

This is kind of a vague question and hard to explain. I'm trying to code my access database, but the VBA portion is really annoying me. Whenever I type something and hit space, it will automatically redo that space and put me back up against the previous word i was typing. Also, Intellisense will come up for a split second, flicker and go away, and revert my cursor to the text that I was just typing. This results in me constantly typing things in places where they shouldn't be and a lack of spaces between elements of my code. Does anyone know why this would be occuring? The database I'm using was created in Access 2007, but I am developing it in 2010. At the top it says Microsoft Access 2007-2010.

Thanks for your help.

Peevish answered 5/6, 2012 at 15:14 Comment(2)
Also see this: #1164638Ahem
That is also helpful and can partially solve the problem, thanks.Peevish
C
13

The most likely cause is that you have a form open with an active timer event.

What is happening is that as you are editing your code, there is code running at some regular interval. Each time that other code runs, the just-in-time compiler for VBA runs.

Normally when you are writing code, this real-time compilation happens whenever you move from one line of code to another: compile errors are raised, trailing white space is trimmed, etc.

However, in your case you have some piece of code that is running. Before it can run, the compiler must run. And it does the same things it normally does. Most annoyingly, it trims trailing white space from your line.


The solution is to close the form with the active timer event, or set the timer interval to 0 while you are editing your code.

Cornice answered 5/6, 2012 at 15:18 Comment(6)
Thank you for your explanation. That seems to have solved it for the most part. The previous developer uses a hidden form with an active timer event, to my understanding, to keep track of "globals." At any rate, closing all the forms seems to fix the problem. Thanks!Peevish
Accepted yours as the correct answer. For some reason forms without any timers still cause this issue though. It's kind of frustrating to have to close these forms while I code. It's a relief typing this response as I don't have to mash my space bar key and reset my cursor:)Peevish
@Scott Do you have the same problem with a new, empty database or is it limited to this particular database?Relish
I do not have this problem with any new databases that I create in Access 2010. I only run into this annoying issue when working on a database that I inherited (which was made in Access 2007). It only happens when I'm working on coding for certain forms, and there's nothing in particular that I see in each form's code that would cause it to continually compile while I'm working on it.Peevish
Open the property sheet for the affected forms, go to the Events tab, and check to see if the On Timer box is filled in (it may be [Event Procedure] or =SomeFunction()). Also, check to see if the Timer Interval box has something other than 0 in it.Cornice
This is annoying, and it took me weeks to figure out what was happening when it did. I'm glad you were able to get an answer.Tapster

© 2022 - 2024 — McMap. All rights reserved.