T
Trois Jay
Objective: to open a remote mdb, loop through the form collection, alter properties\insert code for each form, save it and close the
mdb.
I'm using DAO (opening the other mdb) and iterating through form collection (documents container):
* = code (trailed by '-'); shortened for explanation purposes
- Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)
- Set econ = dbs.Containers!Forms
- For Each edoc In econ.Documents
- etc.*
However, to actually open each form in design mode, within the above For Each... Next loop, I first create another instance of that
same, remote mdb, but then using the Application object, as that provides the DoCmd.Openform method:
- Set appAccess = New Access.Application
- appAccess.OpenCurrentDatabase pstrTempMDBPath, True
- For Each edoc In econ.Documents
- strObjectName = edoc.Name
- appAccess.DoCmd.OpenForm strObjectName, acDesign, , , , acHidden
- etc. *
Although not perfect (can't find another way to do this though), it works fine for unsecured databases.
The trouble starts when the mdb is actually secured with Access security (*.mdw workgroup-file) and an useraccount plus password are
required to open the mdb in design mode.
The 'OpenDatabase' method works fine: by passing the swith-options the mdb is opened properly:
- pstrTempMDBPath = pstrTempMDBPath & " /wrkgrp " & Chr$(34) & CStr(RetVal) & Chr$(34) & _
- " /user " & Chr$(34) & Trim$(Me.txtUserName) & Chr$(34) & _
- " /pwd " & Chr$(34) & Trim$(Me.txtPassword) & Chr$(34)
-
- Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)
Unfortunately, I can't figure out how to open the secured mdb, using the OpenCurrentDatabase-method (because I still need to iterate
through the forms collection and open each form in design mode, for which I use the Docmd method of the Application object).
My problem would be solved if either:
1) I can open forms in design mode using DAO (using Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)) and edit them
or
2) I can open a secured mdb via the Application object (appAccess.OpenCurrentDatabase pstrTempMDBPath, True)
But any solution\suggestion will be welcome.
Thanks in advance!
mdb.
I'm using DAO (opening the other mdb) and iterating through form collection (documents container):
* = code (trailed by '-'); shortened for explanation purposes
- Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)
- Set econ = dbs.Containers!Forms
- For Each edoc In econ.Documents
- etc.*
However, to actually open each form in design mode, within the above For Each... Next loop, I first create another instance of that
same, remote mdb, but then using the Application object, as that provides the DoCmd.Openform method:
- Set appAccess = New Access.Application
- appAccess.OpenCurrentDatabase pstrTempMDBPath, True
- For Each edoc In econ.Documents
- strObjectName = edoc.Name
- appAccess.DoCmd.OpenForm strObjectName, acDesign, , , , acHidden
- etc. *
Although not perfect (can't find another way to do this though), it works fine for unsecured databases.
The trouble starts when the mdb is actually secured with Access security (*.mdw workgroup-file) and an useraccount plus password are
required to open the mdb in design mode.
The 'OpenDatabase' method works fine: by passing the swith-options the mdb is opened properly:
- pstrTempMDBPath = pstrTempMDBPath & " /wrkgrp " & Chr$(34) & CStr(RetVal) & Chr$(34) & _
- " /user " & Chr$(34) & Trim$(Me.txtUserName) & Chr$(34) & _
- " /pwd " & Chr$(34) & Trim$(Me.txtPassword) & Chr$(34)
-
- Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)
Unfortunately, I can't figure out how to open the secured mdb, using the OpenCurrentDatabase-method (because I still need to iterate
through the forms collection and open each form in design mode, for which I use the Docmd method of the Application object).
My problem would be solved if either:
1) I can open forms in design mode using DAO (using Set dbs = wrkJet.OpenDatabase(pstrTempMDBPath, False)) and edit them
or
2) I can open a secured mdb via the Application object (appAccess.OpenCurrentDatabase pstrTempMDBPath, True)
But any solution\suggestion will be welcome.
Thanks in advance!