Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA

Status
Not open for further replies.

tdfreeman

MIS
Mar 28, 2002
85
0
0
US
I have learned coding in Microsoft Access on my own. I never had a Visual Basic class, so I don't know all of the functions available in the VBA code window.

What I was wondering is:

You know how when you are in a query you can right click and select build and you get the expression builder. In the expression builder it lists objects and their controls. Is there a way to see this list in VBA? It would make is easier than finding and typing in the control name in VBA.

Thank you in advance for your help.

Tammy


Thank you for your help.

Tammy
 
while in the VBA window......

{F2}

will bring up the object browser.....

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Not that I know of, but there are two simple ways to do this.

If you're getting a value from an object on your form you can do me. and then VBA will show you a list of objects including your text boxes, and so on.

If you're getting a value from another form than the current one the syntax is Forms!frmName!txtObject

e.g. Forms!frm_Menu!cboRecId

If you simply can't remember or hate typing, go back to your form, and create a text box, then build from that text box and copy the text and paste into the VBA.
 
Thanks.

F2 brings up the object browser, but I have no idea how to use it. I look in classes and find the form name. When I click on it, it opens the forms code in the code window. I want to see the controls on the form.

Is there a way to see this?

Thanks again for your help.

Tammy

Thank you for your help.

Tammy
 
if you use ME then it will use intellisense for you. meaning if you are coding on the FORM MODULE and use the word ME.[object] the object will pop up as you type.

try this

Randall Vollen
National City Bank Corp.

Just because you have an answer - doesn't mean it's the best answer.
 
don't think so......maybe:

if you are on the code for a form, if you type:

me.

you will see a list of all porperties of the form and all the fields in the form are listed there also....

type

me.fieldname.

and you get all the properties for that field.....



****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Thanks for your help. You have answered my question. Unfortunately I am trying to reference another form, not the current form.

Thanks again.

Tammy

Thank you for your help.

Tammy
 
In addition to the Object Browser, you have the VBA help files (provided that it was installed as that is not the default option) These help files gives some general information about what the various objects/methods/properties/events/statements/keywords/miscellaneous are used for. One thing I have noticed to be missing from the help files starting with Office 2000, it doesn't seem to list the various arguments within the events and what they are used for. I had to look online (msdn.microsoft.com) for that info.

You also have within VB Editor, the Project Browser, which allows you to view the various "Class" objects (I.e. Forms, but not command buttons) in your project(s), and you also have the Properties window to view the various properties of an object that's selected in the Browser window, provided that the object has been openned. With these objects, you can double click on it to bring up the module window related to the "Class" object. Once this window is brought up, you can click on the left side of the module window at the top to select the object (which does include all sub objects on the main object such as command buttons that's on the form), then in the right top combobox, select the related event that you want to put code in for.

Of course, there's other ways to achieve the same event selections, but what I mentioned here is just one of the ways to do it.

Now onto Debugging tools:

You can use the immediate window for small minor tests such as what does a particular property of a particular object return currently

?MyForm1.Textbox1.Value

The immediate window has helped me out in seeing how certain properties and functions works.

Watch Window:

You can use this window to see what are the different values of the various properties/functions/variables. This window has been proven to be helpful in 2 ways:

First, it allows the developer to see the results of the item that's in question as the code is being stepped through, and second, when looking for a particular value as far as what property holds it, you can also use this window and don't even have to have code running (unless the property is only set during run-time)

If you are having an issue with your code, you can use break points by clicking on the left side of the module window. When the code is running and comes to this break point, it will NOT run that particular line as it just stops there and takes you to the VB Editor with that line of code showing. An error message will also pop up at this time to give you the option to continue(if allowed), end, debug, or help.

Hopefully, this will help you get started.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top