473,378 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Return Name of All Forms in Database

Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them. I have code that does it
(posted below), but you must open and close the forms...I do not want
this as there may be forms in use that should not be closed.

Dim db As Object
Dim ctr As Object
Dim doc As Object
Dim frm As Form
Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(0)
frm.ShortcutMenu = False
Debug.Print frm.Name
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc

Your help is greatly appreciated!

-Jeremy

Nov 13 '05 #1
2 2060
Here's a query which will do it:

SELECT Name FROM MSysObjects WHERE Type=-32768;

MSysObjects is a system table (one of several), which contains all sorts of
info about the database. If you want to explore further, turn on Show
System Objects in Tools | Options | View. The table doesn't have to be
visible for the query to work.

HTH,

Rob
"Jeremy" <sl********@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them.

<snip>
Nov 13 '05 #2
Rob's query against the system table will definitely work, but there's no
reason you need to open the form to get its name using your code. You
already know the name of the form before you open it, otherwise you wouldn't
be able to open it! And, fwiw, I'd advise declaring the objects explicitly:

Dim db As DAO.Database
Dim ctr As DAO.Container
Dim doc As DAO.Document

Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
Debug.Print doc.Name
Next doc

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Jeremy" <sl********@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hello,

Is anyone aware of a function that will return the name of all forms
contained in a database WITHOUT opening them. I have code that does it
(posted below), but you must open and close the forms...I do not want
this as there may be forms in use that should not be closed.

Dim db As Object
Dim ctr As Object
Dim doc As Object
Dim frm As Form
Set db = DBEngine(0)(0)
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(0)
frm.ShortcutMenu = False
Debug.Print frm.Name
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc

Your help is greatly appreciated!

-Jeremy

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
Here I have two functions, the first returning a value to the second. When I put print_r() on the last line of the first function, I can see that the correct values are in the array as expected....
4
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
0
by: Wayne Aprato | last post by:
Can anyone please help me with the following madness in Access 2003 (2000 file format). I am using 2 similar funtions, the first which works fine to save reports as snapshots: On Error Resume...
20
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
11
by: Ahmet AKGUN | last post by:
Hi; is it possible to open one form in .net platform that we have its name in string ? I have string sFormName = "frmCustomer"; and I must automatically open Customer form. or is it...
3
by: Ken | last post by:
How can I have my WinForm return something to the caller so it knows which button is clicked? The following is calling a system message box, just want to do the samething with my own winform....
2
by: baret bonden | last post by:
Trying to return a selected listbox item to another form .tried lots of ways; defining public variables and passing those as well as textboxes ..I' m able to display the chosen item on it's form...
7
by: pooba53 | last post by:
I am working with VB .NET 2003. Let's say my main form is called Form1. I have to launch a new form (Form2) that gathers input from the user. How can I pass variable information back to Form1...
0
by: jlparise | last post by:
Hey everyone, I am using the JET Provider to read dBase files in C#. I need to use dBase files due to a legacy system only supporting them. I have been having a weird problem here at work with...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.