Getting a list of forms in another Access DB

G

Guest

I am developing an Access DB solution (ver 2002/3) and I have two DB's.

I need to be able to get a list of forms in the 2nd DB while working in the
first DB.

I have been looking at the AllForms collection object, but the help system
(incl Microsoft's web site) assumes that you just want to get the list from
the current DB and there doesn't appear to be a way of accessing the info
from another DB.

Hope somebody can help & thanks

Kind regards

Ross Petersen
 
M

Marshall Barton

Ross said:
I am developing an Access DB solution (ver 2002/3) and I have two DB's.

I need to be able to get a list of forms in the 2nd DB while working in the
first DB.

I have been looking at the AllForms collection object, but the help system
(incl Microsoft's web site) assumes that you just want to get the list from
the current DB and there doesn't appear to be a way of accessing the info
from another DB.


I think this will do that:

Sub listForms()
Dim dbForms As Database
Dim doc As Document

Set dbForms = OpenDatabase("D:\path\file.mdb")
For Each doc In dbForms.Containers!Forms.Documents
Debug.Print doc.Name
Next doc
Set dbForms = Nothing

End Sub
 
A

Alp

Hi Marsh,

Sorry for jumping in but I have a further question on this issue that I've
been looking for a solution:
How would I put the output of this code into a combobox source so it can be
selectable on a form?

Thanks in advance.

Alp
 
D

Douglas J. Steele

One way would be to create a query that reads the MSysObjects in the other
database and use that as the RowSource for your combobox. For forms, you'd
use a query like:

SELECT MSysObjects.Name
FROM MSysObjects IN 'full path to other database'
WHERE (((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;

The full path to the other database is enclosed in single quotes.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Alp said:
Hi Marsh,

Sorry for jumping in but I have a further question on this issue that I've
been looking for a solution:
How would I put the output of this code into a combobox source so it can be
selectable on a form?

Thanks in advance.

Alp
 
A

Alp

Hi Doug,

Can I do a select query in VBA? Because I'd like to use GetOpenFile() to
select the DB for this forms list.

I can't think of how to include a function in the SQL of a stored query. Am
I wrong?

Alp

Douglas J. Steele said:
One way would be to create a query that reads the MSysObjects in the other
database and use that as the RowSource for your combobox. For forms, you'd
use a query like:

SELECT MSysObjects.Name
FROM MSysObjects IN 'full path to other database'
WHERE (((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;

The full path to the other database is enclosed in single quotes.
 
A

Alp

Hi Doug,

Sorry for "false alarm". :-(
Got it finally! Thanks (once again).

Alp

Douglas J. Steele said:
One way would be to create a query that reads the MSysObjects in the other
database and use that as the RowSource for your combobox. For forms, you'd
use a query like:

SELECT MSysObjects.Name
FROM MSysObjects IN 'full path to other database'
WHERE (((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;

The full path to the other database is enclosed in single quotes.
 

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