Question about Using VB6 to Retrieve an Access 2000 Form's Properties

B

bgsmith

Hello.

I am new to VB6 and MS Access working together. Here is my question:

What would the VB6 code look like in order to retrieve
the properties of a form created in Access 2000 and also the properties
of a textbox on the Access 2000 form? The Access 2000 form is a *.mdb
file.

The properties that I want to retrieve from the form are the form's
Width & Height (in Twips) and the textbox's Width & Height (in
Twips).

The end result is that my VB6 program would have the form width
& height and textbox width & height properties' values for its use in
other pats of my VB6 program.

Thank you for your help with this. It is greatly appreciated.
Thanks for helping someone who is new to all of this.

Tom Smith
 
D

Douglas J Steele

As far as I know, the only way would be to use Automation.

Dim objAccess As Object
Dim frmCurr As Object

Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase "C:\MyFolder\MyDatabase.mdb"
objAccess.DoCmd.OpenForm "MyForm"
Set frmCurr = objAccess.Forms("MyForm")

' At this point, you can refer to whatever properties you want in frmCurr

' When you're done, clean up after yourself...
Set frmCurr = Nothing
objAccess.DoCmd.Close 2, "MyForm"
objAccess.CloseCurrentDatabase
Set objAccess = Nothing

The above is using Late Binding: I don't think it's necessary to add a
reference to Access in your VB app, but I haven't tested. (If you do have a
reference to Access, you may want to replace the 2 in the DoCmd.Close line
to acForm to make your code more readable!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top