cricketbird
Registered User.
- Local time
- Today, 02:44
- Joined
- Jun 17, 2013
- Messages
- 111
I am taking a large database (split front/back, 85 forms) and creating a script so that users can switch all of the button and label captions on each form to their local language.
The eventual script will use a table like this:
...to set the caption of each control. The script to update the controls using this table is working fine.
In order to populate this table in the first place, though (so we can send the captions out for translation), I have the code below that loops through each form and gathers the necessary table data about the controls from each form. The code itself works fine (debug.printing here, but eventually the intention is to write to a file). The problem is that about 20 forms in (out of 80+), I get the error "Cannot open any more databases".
1) Is there a way to loop through controls or gather the necessary data without OPENING each form?
or, alternatively,
2) Is there a way to "clear the database connections" after I close each form?
Thank you!
The eventual script will use a table like this:
TableName | ControlName | LanguageCode | CaptionText |
Form1 | Button1 | en | |
Form1 | Button1 | de |
In order to populate this table in the first place, though (so we can send the captions out for translation), I have the code below that loops through each form and gathers the necessary table data about the controls from each form. The code itself works fine (debug.printing here, but eventually the intention is to write to a file). The problem is that about 20 forms in (out of 80+), I get the error "Cannot open any more databases".
1) Is there a way to loop through controls or gather the necessary data without OPENING each form?
or, alternatively,
2) Is there a way to "clear the database connections" after I close each form?
Thank you!
Code:
Public Sub GetForms()
On Error Resume Next
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
Debug.Print obj.Name
If obj.IsLoaded = False Then DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
DoEvents
GetControls (obj.Name)
DoCmd.Close acForm, "[" & obj.Name & "]"
Next obj
End Sub
Sub GetControls(ByVal oForm As String)
Dim oCtrl As Control
Dim cOutputString As String
For Each oCtrl In Forms(oForm).Controls
Select Case oCtrl.ControlType
Case acLabel: cOutputString = Forms(oForm).Name & vbTab & oCtrl.Name & vbTab & oCtrl.Caption
Case acCommandButton: cOutputString = Forms(oForm).Name & vbTab & oCtrl.Name & vbTab & oCtrl.Caption
End Select
Debug.Print cOutputString
Next
End Sub