This is part one of a three part series on the Access IDE. Part II can be found here and Part III here.
I work in the Access IDE, (Integrated Development Environment), all day and it helps to know a few tricks or ten on how to take advantage of the environment.
10. Before you can fix your code you need to break it first.
Who among us can write perfect code every time on our first try? That’s why I always break new code when I run it for the first time, stepping through it so I know it’s working as I designed it. You can break your code by clicking on the left border of the IDE and inserting a red break point. Use F8 to step through or F5 to run it at normal speed.
9. Immediate Window
Control-G quickly became my favorite way to get to the Access immediate window where you can work wonders:
You can do math, for example, type ?5*2 and the compiler responds 10.
You can inspect properties while your code is in break mode, for example, I can query the first control in the control’s collection of the active form:
I can even run functions and re-assign variable values, below I ask the system for the value of my variable strSQL, then I re-assign a value, (notice you don’t use the ? when assigning values), then I ask again for the new value of the variable:
8. Find and Replace Globally
Control-F will bring up the search dialog, where you can limit the search to just the current procedure, module or all of your code. Control-H will bring up the search and replace dialog box. Handy if you need to do a global replace in the current procedure for a variable name, constant, etc.
7. Move the execution point
You can drag the yellow arrow when debugging your code, just grab the yellow arrow on the left and move it up or down, great when you want to re-run a block of code again.
6. Dual Windows
Sometimes I need to see the list of variables at the top of my procedure as I’m adding new lines of code. That can be a problem if I have a long procedure and my declaration area is gone from the top. That’s when this tip comes in handy: Just move your cursor to the upper right hand top of the vertical scroll bar, until it turns into double arrow, then click and drag to create a split view of your screen.
You will then see two panes where you can display different lines from the same module:
To go back to just one pane double click on on the horizontal pane border.
5. Bookmark your way back
Bookmarks are a great way to tag your line of code, go somewhere else and quickly come back. You can insert a bookmark by clicking the bookmark icon on the edit toolbar:
The only drawback is you lose the bookmarks you’ve created once Access is closed down.
4. Explorer your code
Press Ctrl-R to view the explorer window where you can double click on any object to see their code.
3. Right click to find definitions
You can see a variable’s declaration or see the code behind a subroutine or function by right clicking on them and selecting “Definition”.
2. Leave yourself a non-comment
Sometimes I need to abandon incomplete code to work on another project. I got tired of figuring out where I had left off, (is it the onset of senility or information overload?), so now I deliberately leave a non-comment that will cause the compiler to error out: CONTINUE HERE is one of my favorites. When I get back I just compile the project and Access takes me where I left off. I erase the comment and keep going.
And my number one tip is…
1. Get the white out
I stare at my screen all day and the default white background of the IDE was killing me, that is until I discovered how to change it. Below is how my IDE looks, the beep blue background makes it very easy on the eyes. You can change the appearance by clicking on Tools, Options and then clicking on the Editor Format tab. Notice how keywords such as Dim and String are in green, making it easier to view your code.
In a future post I’ll be discussing my top annoyances about the IDE and close out the series with some of my favorite tools for Access developers.
What is your number one favorite IDE feature? Submit a comment below for a chance to win a $25 Amazon gift card!
I never considered changing the background color, though I knew you could. Looking at your screenshots, I think I like that idea, but I wonder if you ever considered yellow, like a legal notepad?
I also like the whole idea about breaking your code, though I have never purposefully done that. I do often times find myself trying to figure out why the code is broken (unintentionally), or isn’t doing what it’s supposed to be, though the code executes just fine. I can spend quite a bit of time trying to figure it out, then get up to take a break, get by onto my computer and the solution is staring me right in the face – am I the only one that this happens to, I wonder?
I think you are not the exception when it comes to not breaking code. I’ve met a lot of people who don’t want to or did not know how. I personally think you need to break every time you run new code.
I think there are a bunch of really good things about the IDE screen. A few more below.
When you have a form or module with a lot of modules there is a drop down in the middle upper part (under the menus in the middle of the screen) that allow you to jump between modules. Above the properties window (probably not actually the name of it) with the list of forms/modules there is a button for “view source” that will jump you back to the related form. Clear all breakpoints (Ctrl+Shift+F9) is a nice thing too.
I never used the properties window, thanks for letting me know what it’s for, always went back to the front end to change them!
I never even thought about changing the background color of the IDE. And I’ve never used the bookmarks. Both tips were helpful.
Number 2 is my favorite tip. I have same problem in that days or a week may go by before I can resume a project, especially a volunteer one.
You covered a lot in this article about the IDE. My personal favorite is using Watches. This is especially helpful when dealing with recordsets in complicated and you need to the see what is going on when you get to a certain record. Or just to check on the values of variables in a module.
Good point. Usually I’ll just hover over the variable to see the value at that time or I use the immediate window along with the “?” to display the value. A recordset however has many fields, which you can see during the watch.
Did you learn any new features from my post? If so, which ones? Thanks for comenting!
Thanks, Juan for sharing.
I fooled with customizing colors but found out that though it’d look nice, the windows on side can’t be customized, resulting in mismatch which for me at least personally was too glaring so back to ol’white. I have to admit, I’m extremely surprised that there was always support for colorizing keywords. Why didn’t they make it default as they do with Visual Studio. So bizarre.
As for my personal feature, (and I’m assuming we’re talking vanilla IDE here), it’d be definitely the Properties windows (F4) which I always have docked underneath the Explorer. That way, it saves me a trip to the Access if I want to quickly see what a particular UI property is set to or verify that there’s a “[Event Procedure]” for the event I want to use or as a quick way to name/rename a module.