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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing MSAccess Forms Control Properties from VB6??

Status
Not open for further replies.

TIGREBLANCO

Programmer
Feb 23, 2003
38
0
0
US
Hi, hope someone can help:

This is a VB6 program trying to get access to all the properties in a given MS Access Form's control (i.e. textbox.caption).
I can connect a variable to the MS Access Object Collection (set accessapp = createobject(access.application)), but can't seem to find the way to access the properties of the controls on any given form.
When I look at the AccessApp object in my Watch Window (in vb6) I can see the objects (tables, queries, etc) but under the forms collection I see: [+]Item 1.....[+]Item 4 (my database has four forms so far).
Why in the world am I not seen the names of the forms (i.e. Login_frm) instead of "Item 1".
My question is then: How can vb6 access the properties of any control within any given MS Access form.
I've automated excel with ease, but the Access Object Collection seems to behave a little bit different, I'm kind of lost on this one.
I hope I provided all necessary info, please let me know if otherwise.

Any Ideas ne1?

Regards.
 
Off the top of my head I wouldn't expect ACCESS to expose it's internal controls' references when an instance of it was created. Anything you wanted to get at from vb would need to be exposed as an interface. EXCEL exposes items like the contents of individual cells through automation, but I suspect that if you created forms in EXCEL then you wouldn't be able to access objects in them without special coding.

Phil
 
hmmmmmmmmmmmm,

Seems like the long way around the barn, since - having the db available - it would be somewhat more direct to get the info directly from the .mdb. Still, it has some appeal at least as an exercise in exploring ... stuff.

I would think that even though the objects within the collection show up with ('system') assigned (rather than User given) names, they would still posses a properties collection - one of which might be UserName. At least, attempt to instantiate the documents collection of the forms and see if the items within the collection expose their properties.

If you send me a copy of the procedure you have so far, I would at least attempt to review it and see if I can traverse the heirachy to the controls collection of a form.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thanks for your thoughts, and sorry it took me so long to get back to this thread, just too busy.
So far I've found a way to pass info from my prog in vb into the Access textbox or any control, by writing the info into a txt file and then forcing the control to read that file's content and incorportate it into its value.
Its simple and it works, but I'm genuenly interested in knowing how to access the properties of any MS Access control directly form VB6.
There is only one other way I think this can be done and it is through API (haven't done it yet, but try it will soon).
Michael, thanks for offering to take a look at my code, I will post it as soon as I get home (@work now).
 
Hi there

I just found out how to access the properties in an MS Access form's control, it can be done through "screen" or "forms" objects (I still can't understand why the object browser won't display the items (ie. forms, controls) by its name (like Excel does) rather that "Item 1" name specification, not very happy with this).

So in order to get the value from a text box "Area_Tbx" in Form "Login_frm" use:
StrTemp = AccessApp.Forms.Login_frm.Area_Tbx.value

or if Login_frm is the the active form (the one with the focus):
StrTemp = AccessApp.ActiveForm.Area_Tbx.value

Good Luck!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top