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

Output all the settings for all the controls in all the forms 1

Status
Not open for further replies.

sub5

Programmer
Oct 12, 2005
104
Hello All,
I want to output all the property settings for all the forms in an Access97 database to a text file.
ie if control1 onclick event setting is =fncEmail(), I want that to be my output.

I only seem to be able to get it to demand the value (rather than the setting) for the property when the form is open in normal view.

I have tried messing around with object variables but that hasn't helped.

Any ideas, is it possible?

Public Function AllformsData()
Dim dbs As Database
Dim doc As Document
Dim form1 As String
Dim frm As Form
Dim ctl As control
Dim prp As Property
Dim frmName As Form
Dim ctlName As control
Dim prpName As Property

Set dbs = CurrentDb

Open "TEXTproperty.txt" For Output As #1

For Each doc In dbs.Containers!Forms.Documents
form1 = doc.Name
DoCmd.OpenForm form1, acDesign
For Each frm In Forms
'Set frmName = frm.Name
Write #1, "Form: " & frm.Name
For Each ctl In frm.Controls
'Set ctlName = frmName.Name
Write #1, "Control: " & ctl.Name
For Each prp In ctl.Properties
'Set prpName = frmName.Name
Write #1, prp.Name & "=" & prp
'Write #1, prp.Name & "=" & prpName
Next prp
Next ctl
DoCmd.Close acForm, form1
Next frm
Next doc

Close #1
End Function
 
What do you get for the event properties that have values?

I would think you would have to open the form's module and read any VBA out of it. I have never played with that but I'm pretty sure it is supported. Not sure how you would get at a forms module... Hopefully it has a module property (it does have a HasModule property).
 
I think your in luck. I just wrote this for another thread,
thread702-1206622.
 
Hi MajP

Using ScreenActive was inspired, cheers MajP.

I have modified the code so that I can loop through all the forms in my DBase, but I have a problem with the sections, my mind is blocked I can't workout how to to a for each style loop through any sections a form has, consequently I get errors for forms with only detail say.

Any ideas on how to loop through the sections?

Public Function getPropsAllFormsXls()

On Error GoTo errLable

Dim dbs As Database
Dim myDoc As Document
Dim myCntrl As Access.control
Dim myProperty As Property
Dim myForm As Access.Form
Dim docForm As String
Dim ErrorInd As Integer
Dim mySection As Section
Dim secName As Section

Set dbs = CurrentDb

Open "ContolProperty.txt" For Output As #1
Write #1, "Form", "Control", "Property", "Setting"

For Each myDoc In dbs.Containers!Forms.Documents
docForm = myDoc.Name
DoCmd.OpenForm docForm, acDesign
Set myForm = Screen.ActiveForm
ErrorInd = 1
For Each myProperty In myForm.Properties
Write #1, myForm.Name; myForm.Name; myProperty.Name; myProperty.Value
Next myProperty
ErrorInd = 2
'For Each mySection In myForm
For Each myProperty In myForm.Section(0).Properties
Write #1, myForm.Name; myForm.Section(0).Name; myProperty.Name; myProperty.Value
Next myProperty
For Each myProperty In myForm.Section(1).Properties
Write #1, myForm.Name; myForm.Section(1).Name; myProperty.Name; myProperty.Value
Next myProperty
For Each myProperty In myForm.Section(2).Properties
Write #1, myForm.Name; myForm.Section(2).Name; myProperty.Name; myProperty.Value
Next myProperty
For Each myProperty In myForm.Section(3).Properties
Write #1, myForm.Name; myForm.Section(3).Name; myProperty.Name; myProperty.Value
Next myProperty
For Each myProperty In myForm.Section(4).Properties
Write #1, myForm.Name; myForm.Section(4).Name; myProperty.Name; myProperty.Value
Next myProperty
'Next mySection
ErrorInd = 3
For Each myCntrl In myForm.Controls
For Each myProperty In myCntrl.Properties
Write #1, myForm.Name; myCntrl.Name; myProperty.Name; myProperty.Value
Next myProperty
Next myCntrl
DoCmd.Close acForm, docForm
Next myDoc

Close #1

Exit Function

errLable:
Select Case Err.Number
Case 2186, 2196
If ErrorInd = 1 Then Write #1, myForm.Name; myForm.Name; myProperty.Name; "can not get property value"
If ErrorInd = 2 Then Write #1, myForm.Name; myForm.mySection.Name; myProperty.Name; "can not get property value"
If ErrorInd = 3 Then Write #1, myForm.Name; myCntrl.Name; myProperty.Name; "can not get property value"
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
Resume Next

End Function
 
just modified the error handling to patch the problem (a loop statement would be better!):

errLable:
Select Case Err.Number
Case 2186, 2196
If ErrorInd = 1 Then Write #1, myForm.Name; myForm.Name; myProperty.Name; "can not get property value"
If ErrorInd = 2 Then Write #1, myForm.Name; myForm.mySection.Name; myProperty.Name; "can not get property value"
If ErrorInd = 3 Then Write #1, myForm.Name; myCntrl.Name; myProperty.Name; "can not get property value"
Case 2462, 92
Resume Next
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
Resume Next

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top