Guillem
Member
- Local time
- Today, 06:56
- Joined
- Mar 28, 2020
- Messages
- 32
Hello, can someone help with this confusing(for me) things?
Is it possible to have a list of Forms, choosing both from the local database or another selected database. I tried many combinations but unsuccessfully. The code that follows works fine from local db, but fail trying with an external db.
Here is the code :
<<
Dim pLocal As Boolean
Dim DbsExt As String
Dim appAccess As Access.AccessObject
Dim db As Access.AccessObject
Dim obj As Access.AccessObject
Dim frm As Access.Form
DbsExt = "set to FilePath of Existing .accdb database"
pLocal = False 'set true for local db, false for external db
Set db = Nothing
If pLocal = True Then 'Local Forms
Set db = CurrentProject
Else 'External Forms
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase DbsTxt, True
Set db = appAccess
End If
'do Forms
For Each obj In db.AllForms 'FAILS for external DBs
Debug.Print "Form = " & obj.Name
Next
>>
it’s probably easier to do separate procedures ... but I’d like to understand these differences.
Thank you.
Is it possible to have a list of Forms, choosing both from the local database or another selected database. I tried many combinations but unsuccessfully. The code that follows works fine from local db, but fail trying with an external db.
Here is the code :
<<
Dim pLocal As Boolean
Dim DbsExt As String
Dim appAccess As Access.AccessObject
Dim db As Access.AccessObject
Dim obj As Access.AccessObject
Dim frm As Access.Form
DbsExt = "set to FilePath of Existing .accdb database"
pLocal = False 'set true for local db, false for external db
Set db = Nothing
If pLocal = True Then 'Local Forms
Set db = CurrentProject
Else 'External Forms
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase DbsTxt, True
Set db = appAccess
End If
'do Forms
For Each obj In db.AllForms 'FAILS for external DBs
Debug.Print "Form = " & obj.Name
Next
>>
it’s probably easier to do separate procedures ... but I’d like to understand these differences.
Thank you.
Last edited: