oldfryeguy
New member
- Local time
- , 20:08
- Joined
- Dec 27, 2023
- Messages
- 11
I learned a bit of SQL in a free class a few years ago. But now with my second database gig I'm hitting VBA hard. What are the most used skills or objects?
By far, in VBA, the thing that will give you the most power is debugging with the immediate window, the locals window and playing with intellisense. Practice both getting and setting the things you see in those two and you'll find a world of undocumented knowledge.I learned a bit of SQL in a free class a few years ago. But now with my second database gig I'm hitting VBA hard. What are the most used skills or objects?
Thanks! In my VBA code editor, the immediate box never displays output of any kind. I googled and read for several hours yesterday, couldn't find a solution. Also, if I 'play button ' - run code, a pop up box asks what macro I would like to run. I was able to run code from the access form where the buttons are located.Welcome to the forum.
Most used skills and objects?
Most Used Skills:
The ability to step far enough away from the tree to see the forest.
The ability to approach things methodically (as opposed to stepping in and shooting from the hip.)
The ability to recognize that objects have fine structure; that they frequently convey multiple items of information.
Most Used Objects: (Object names highlighted in blue)
Probably Recordsets (which rely on Tables, TableDefs, Queries, and QueryDefs);
Forms (which employ Controls to display limited amounts of data from Recordsets);
Reports (which employ Controls to display lots of data from Recordsets)
Every object has an object type, and the Intellisense feature can help you see & select the properties of your object of interest. Which is why you want to remember to use the proper type of object declaration rather than using generic objects.
Thanks! In my VBA code editor, the immediate box never displays output of any kind. I googled and read for several hours yesterday, couldn't find a solution. Also, if I 'play button ' - run code, a pop up box asks what macro I would like to run. I was able to run code from the access form where the buttons are located.By far, in VBA, the thing that will give you the most power is debugging with the immediate window and playing with intellisense. Practice both getting and setting the things you see in those two and you'll find a world of undocumented knowledge.
Take Doc's suggestion for most used objects. Want to know what a recordset has? declare a recordset variable and see what items intellisense give you. Want to see what data, collections and properties it comes with and how to access them? initialize the variable and inspect it in the immediate window. The entire setup can be visualized and you don't have to memorize anything, you get references to everything in the database from there. Got an error? check the immediate window and instantly see why you got that error.
I'm not good at this yet but I do this as best I can. One problem is I crash. I become too detailed and have to research if something will work. Then I start testing code. How do you know -what-exactly to document?Other considerations-
- put Option Explicit at the top of every module
- To try not to get a single sub/function to do more than one task
- give your controls and variables, subs and functions meaningful but not too long names
- Use indentation properly so code is easy to follow
- Document your code to describe what it suppose to do
my usual method is to write the documentation first ( it can always be tweaked) to describe what each step is required to do
Then the loops/iifs etc indented that are anticipated to complete the step
Finally the code itself
How can I know what going to happen if several forms are opened?
How do you know -what-exactly to document?
Highly recommend watching @sonic8 's Better VBA series. It will get you started and primed for the "hard stuff".I learned a bit of SQL in a free class a few years ago. But now with my second database gig I'm hitting VBA hard. What are the most used skills or objects?
By far, in VBA, the thing that will give you the most power is debugging with the immediate window and playing with intellisense. Practice both getting and setting the things you see in those two and you'll find a world of undocumented knowledge.
Take Doc's suggestion for most used objects. Want to know what a recordset has? declare a recordset variable and see what items intellisense give you. Want to see what data, collections and properties it comes with and how to access them? initialize the variable and inspect it in the immediate window. The entire setup can be visualized and you don't have to memorize anything, you get references to everything in the database from there. Got an error? check the immediate window and instantly see why you got that error.
That's correct, I was confusing the name of the window I want you to see, the window name is Locals. You see outputs from writing Debug.Print on the immediate window or using this syntaxthe immediate box never displays output of any kind
?variable
. You'll see outputs on the Locals window if you get an error and click Debug:You were trying to run Class module code, that code only runs when the Class is initialized. The code you write inside a Form is Class module code. If you want to use the Play button to run code, try adding a regular module from the Insert menu. Then add your code there and you'll be able to run it if your cursor is inside a subroutine without parameters.Also, if I 'play button ' - run code, a pop up box asks what macro I would like to run
?MySub(someParam)
, for example: ?Left("hello",2)
and hit enter, it will return "he". But you can also do some programming there if you ever need that, for example, write tomorrow=29
and then hit enter and then write ?tomorrow
and hit enter, and it will return 29.or a module with nothing but functionsYou were trying to run Class module code, that code only runs when the Class is initialized