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

How to get the Record Source field from a known form?

P: n/a
With the code listed below I can get a list of all the forms within my
database. Is there a way to also get the Record Source property from each
of these forms? How is this done?

Thanks
Dustin Wilson

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Not from the AccessObject object, no. These objects have only a handful of
properties, to get further information you need to open the form. For
example ...

For Each obj In dbs.AllForms
Debug.Print obj.Name
DoCmd.OpenForm obj.Name
Debug.Print Forms(obj.Name).RecordSource
DoCmd.Close obj.Name
Next obj

--
Brendan Reynolds
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:FP****************@news1.mts.net...
With the code listed below I can get a list of all the forms within my
database. Is there a way to also get the Record Source property from each
of these forms? How is this done?

Thanks
Dustin Wilson

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj

Nov 12 '05 #2

P: n/a
Brendan

This works in that it gives me the RecordSource for each form but I get an
error at the line below:

DoCmd.Close obj.Name

Error message is:
Run-time error '13':
Type mismatch

Is there a way to get this to run without this error?

Thanks
Dustin Wilson
"Brendan Reynolds" <br******@removethisindigo.ie> wrote in message
news:X_*****************@news.indigo.ie...
Not from the AccessObject object, no. These objects have only a handful of
properties, to get further information you need to open the form. For
example ...

For Each obj In dbs.AllForms
Debug.Print obj.Name
DoCmd.OpenForm obj.Name
Debug.Print Forms(obj.Name).RecordSource
DoCmd.Close obj.Name
Next obj

--
Brendan Reynolds
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:FP****************@news1.mts.net...
With the code listed below I can get a list of all the forms within my
database. Is there a way to also get the Record Source property from each of these forms? How is this done?

Thanks
Dustin Wilson

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj


Nov 12 '05 #3

P: n/a
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:4G****************@news1.mts.net...
Brendan

This works in that it gives me the RecordSource for each form but I get an
error at the line below:

DoCmd.Close obj.Name

Error message is:
Run-time error '13':
Type mismatch

Is there a way to get this to run without this error?

Thanks
Dustin Wilson

Try amending the line to:
DoCmd.Close acForm, obj.Name

Fletcher
Nov 12 '05 #4

P: n/a
Oops! Sorry, Dustin, I typed that from memory without testing it. Fletcher
and Chuck have given the answer.

--
Brendan Reynolds
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:4G****************@news1.mts.net...
Brendan

This works in that it gives me the RecordSource for each form but I get an
error at the line below:

DoCmd.Close obj.Name

Error message is:
Run-time error '13':
Type mismatch

Is there a way to get this to run without this error?

Thanks
Dustin Wilson
"Brendan Reynolds" <br******@removethisindigo.ie> wrote in message
news:X_*****************@news.indigo.ie...
Not from the AccessObject object, no. These objects have only a handful of
properties, to get further information you need to open the form. For
example ...

For Each obj In dbs.AllForms
Debug.Print obj.Name
DoCmd.OpenForm obj.Name
Debug.Print Forms(obj.Name).RecordSource
DoCmd.Close obj.Name
Next obj

--
Brendan Reynolds
"Dustin Wilson" <dw*****@REMOVE.kgsgroup.com> wrote in message
news:FP****************@news1.mts.net...
With the code listed below I can get a list of all the forms within my
database. Is there a way to also get the Record Source property from

each of these forms? How is this done?

Thanks
Dustin Wilson

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
debug.print obj.Name
Next obj



Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.