Controls in a external DB

  • Thread starter Javier G via AccessMonster.com
  • Start date
J

Javier G via AccessMonster.com

Hi,
I have a problem to get infomation of ALL CONTROLS from all forms in a
external DB (Not linked)

My code is:

'********* START CODE ****************
Dim app As Object
Dim frm As Form
Dim ctl As Control
Dim strPathBD As String
Dim strPassword As String


Set app = CreateObject("Access.Application")
app.OpenCurrentDatabase strPathBD, False, strPassword

For Each frm In app.CurrentProject.AllForms
' MsgBox "FORM= " & frm.Name, vbExclamation

If Not CurrentProject.AllForms(frm.Name).IsLoaded Then
app.DoCmd.OpenForm frm.Name, acDesign, , , , acHidden
End If

For Each ctl In frm.Controls
MsgBox "FORM= " & frm.Name & vbCrLf & _
"CONTROL= " & ctl.Name & vbCrLf & _
"VALUE = " & ctl.Value & vbCrLf & _
"TYPE= " & ctl.ControlType
Next ctl

app.DoCmd.Close acForm, frm.Name, acSaveNo
Next frm

app.CloseCurrentDatabase
Set app = Nothing

MsgBox "FIN"

'******* FINNISH *************

Appreciate your help
Javier
 
B

Brendan Reynolds

The Value property is not available in design view.

If you choose to open the forms in normal form view, the Value property will
be available, but some control types, such as lines and labels, don't have a
Value property. You'll need to either check the ControlType property before
attempting to refer to the Value property, or trap the error that will be
raised if you attempt to refer to the Value property of a control type that
doesn't have a Value property.

It would take too long for me to provide an example that works from outside
Access via automation, but here's an example that works in Access. Hopefully
it shouldn't be too difficult to modify ...

Public Sub ListControls()

Dim aob As AccessObject
Dim frm As Form
Dim ctl As Control
Dim boolOpened As Boolean

For Each aob In CurrentProject.AllForms
Debug.Print "Form: " & aob.Name
DoCmd.OpenForm aob.Name
Set frm = Forms(aob.Name)
For Each ctl In frm.Controls
Debug.Print "Control: " & ctl.Name
Debug.Print "Type: " & ctl.ControlType
On Error Resume Next
Debug.Print "Value: " & ctl.Value
On Error GoTo 0
Next ctl
DoCmd.Close acForm, aob.Name
Next aob

End Sub
 
J

Javier G via AccessMonster.com

thank you for your support

Sorry but your code is wrong ONLY shows present (active) DB does Not shows
the controls FORMS from the destination (external) DB.

Does any body can help ?

Javier
 

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