By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

How to get Form properties from Workspace?

P: n/a
I need to get the Form properties of an mdb I've opened as a Workspace. How
do I access the Forms collection? I'm not sure how to navigate the object
model here... or if that is even my problem...

Private Sub DocumentForm(ByVal strName As String)
Dim db As DAO.Database
Dim wrk As DAO.Workspace
varV = "C:\Documents and Settings\Administrator\My
Documents\Database\My.mdb"
Set wrk = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrk.OpenDatabase(varV, True)
Set frm = Forms(strName)
For Each frm In db.Containers '<<== ?? how to get Form properties from
My.mdb ??
[code omitted]
Next
End Sub
Thanks!!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
From what I can tell, Form properties are in the Application collection.
So, as in Outlook automation, do I need something like:

Dim frm As Form
Dim acc As New Access.Application
Set acc = acc(C:\my.mdb)

DoCmd.OpenForm strName, View:=acDesign, WindowMode:=acHidden
Set frm = acc(strName)
AddProps rstObj, rstProps, frm, "Form", lngParentID

The purpose here is to get all the Form properties from an mdb that is not
open.
This works great on the current database:

Private Sub DocumentForm(ByVal strName As String, ByVal lngParentID As Long)
Dim db As Database
Dim rstObj As DAO.Recordset
Dim rstProps As DAO.Recordset
Dim lngObjectID As Long
Dim frm As Form
Dim ctl As Control
Dim intI As Integer
Dim obj As Object
Set db = CurrentDb()
DoCmd.OpenForm strName, View:=acDesign, WindowMode:=acHidden
Set rstObj = db.OpenRecordset("zstblSubObjects", dbOpenTable,
dbAppendOnly)
Set rstProps = db.OpenRecordset("zstblProperties", dbOpenTable,
dbAppendOnly)
Set frm = Forms(strName)
AddProps rstObj, rstProps, frm, "Form", lngParentID
For intI = 0 To 4
Set obj = frm.Section(intI)
AddProps rstObj, rstProps, obj, "Section", lngParentID
Next intI
For Each ctl In frm.Controls
AddProps rstObj, rstProps, ctl, GetControlType(ctl), lngParentID
Next ctl
DoCmd.Close acForm, strName
End If
Nov 12 '05 #2

P: n/a
This seems to be working:

Dim db As DAO.Database
Dim rstProps As DAO.Recordset
Dim rstObj As DAO.Recordset
Dim lngObjectID As Long
Dim frm As Form
Dim ctl As Control
Dim intI As Integer
Dim obj As Object
Dim acc As Access.Application
Application.Echo False
Set db = CurrentDb()
Set rstObj = db.OpenRecordset("mtblSubObjects", dbOpenTable,
dbAppendOnly)
Set rstProps = db.OpenRecordset("mtblProperties", dbOpenTable,
dbAppendOnly)
Set acc = CreateObject("Access.Application")
acc.OpenCurrentDatabase varV
acc.Visible = False
acc.DoCmd.OpenForm strName, View:=acDesign, WindowMode:=acHidden
Set frm = acc.Forms(strName)
AddProps rstObj, rstProps, frm, "Form", lngParentID
For intI = 0 To 4
DoEvents
Set obj = frm.Section(intI)
AddProps rstObj, rstProps, obj, "Section", lngParentID 'AddProps is
a sub that loads up a table from the recordsets
[code omitted]
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.