Form Descriptions

B

Brian Smith

Is it possible using VBA to collect the descriptions (those entered under
Properties in the database window) of all Forms and insert them to a table
along with the names of the forms? If so, I'd greatly appreciate it if
someone could point me in the direction of some code examples.

Thanks.

Brian
 
G

Guest

Brian

I have sent you a PM with a DB I found which may help you

(to much code to post on forum)

regards

Paul
 
D

David C. Holley

Yeppers.

You would use DAO to snoop around the MSysObjects system table. The
example below opens the form in design mode, reads the value for the
CAPTION property and then saves adds a record to a table named
'tblSnooperResults' with the form name and the form's caption. FYI -
Each object has a corresponding record in MSysObjects. Form objects are
idenfied as type -32768.

Roughly...

Set db = CurrentDB()
Set rs = db.OpenRecordSet("SELECT * FROM MSysObjects WHERE TYPE =
-32768;", dbOpenForwardOnly)
Set targetRS = db.OpenRecordSet("tblSnooperResults")

While not rs.EOF
DoCmd.OpenForm rs.Fields("name"), acDesign
set frm = Forms(rs.fields("name"))
targetRS.AddNew
targetRS("formName") = rs.Fields("name")
targetRS("description") = frm.Caption
targetRS.Update
DoCmd.CloseForm acForm, frm.Name
set frm = nothing
rs.MoveNet
wend
targetRS.close
rs.close

Set targetRS = Nothing
Set rs = Nothing
 
M

Marshall Barton

Brian said:
Is it possible using VBA to collect the descriptions (those entered under
Properties in the database window) of all Forms and insert them to a table
along with the names of the forms? If so, I'd greatly appreciate it if
someone could point me in the direction of some code examples.


Here's the full reference to a form's decription:

CurrentDb.Containers!Forms.Documents!nameofform.Properties!Description

Here's the outline of a procedure to get the description for
all the forms:

Set db = CurrentDb()
Set rs = db.OpenRecordset(nameoftable)
On Error Resume Next 'avoid error when no description
With db.Containers!Forms
For Each doc In .Documents
rs.AddNew
rs!FormName = doc.Name
rs!Descr = doc.Properties!Description
rs.Update
Next doc
End With
rs.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top