How can I find if form is available in database or not?

S

Sunny

I am using switchboard for my application menu and all my menuoptions are
stored in switchboard table. So whenever I add new features to my
application menu automatcially change. Some users of my application are
using package and new features is not included until I create new package. I
want this feature available to my other users as soon as I am done with it.
How can I check if form or report or mudule is available in database before
I call it?

Thanks.
 
S

Sandra Daigle

You can call a function similar to the one below to test for it by name:

Public Function FormExists(strFormName As String) As Boolean
Dim fExists As Boolean
Dim db As dao.Database
Dim intI As Integer
Set db = CurrentDb()
Do Until intI = db.Containers("Forms").Documents.Count - 1 Or fExists
If db.Containers("Forms").Documents(intI).Name = strFormName Then
fExists = True
Else
intI = intI + 1
End If
Loop
FormExists = fExists
Set db = Nothing
End Function

If you have Access XP or above you can use the AllForms collection of the
currentproject instead of using the documents collection of the "Forms"
member of the Containers collection.

I would probably make some changes to the switchboard to disable
forms/reports that don't exist before you display the switchboard.
 
S

Sunny

Thanks Sandra, works great.

I have created one module (MyLibrary) which stores all my common functions
used by the application. Is there any way to find if function (or sub)
exitsts in the module?

Thanks again.
Sandra Daigle said:
You can call a function similar to the one below to test for it by name:

Public Function FormExists(strFormName As String) As Boolean
Dim fExists As Boolean
Dim db As dao.Database
Dim intI As Integer
Set db = CurrentDb()
Do Until intI = db.Containers("Forms").Documents.Count - 1 Or fExists
If db.Containers("Forms").Documents(intI).Name = strFormName Then
fExists = True
Else
intI = intI + 1
End If
Loop
FormExists = fExists
Set db = Nothing
End Function

If you have Access XP or above you can use the AllForms collection of the
currentproject instead of using the documents collection of the "Forms"
member of the Containers collection.

I would probably make some changes to the switchboard to disable
forms/reports that don't exist before you display the switchboard.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I am using switchboard for my application menu and all my menuoptions
are stored in switchboard table. So whenever I add new features to my
application menu automatcially change. Some users of my application
are using package and new features is not included until I create new
package. I want this feature available to my other users as soon as I
am done with it. How can I check if form or report or mudule is
available in database before I call it?

Thanks.
 
S

Sandra Daigle

You can use the Find method of the Module object to search for specfic
strings. The module must first be opened using DoCmd.OpenModule.

My preference though would be to put new code into a new module and then
search for existance of the new module. I am very leary about having
production code that opens modules (for a variety of reasons). This
definately wouldn't work in an MDE.


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Thanks Sandra, works great.

I have created one module (MyLibrary) which stores all my common
functions used by the application. Is there any way to find if
function (or sub) exitsts in the module?

Thanks again.
Sandra Daigle said:
You can call a function similar to the one below to test for it by
name:

Public Function FormExists(strFormName As String) As Boolean
Dim fExists As Boolean
Dim db As dao.Database
Dim intI As Integer
Set db = CurrentDb()
Do Until intI = db.Containers("Forms").Documents.Count - 1 Or fExists
If db.Containers("Forms").Documents(intI).Name = strFormName Then
fExists = True
Else
intI = intI + 1
End If
Loop
FormExists = fExists
Set db = Nothing
End Function

If you have Access XP or above you can use the AllForms collection
of the currentproject instead of using the documents collection of
the "Forms" member of the Containers collection.

I would probably make some changes to the switchboard to disable
forms/reports that don't exist before you display the switchboard.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I am using switchboard for my application menu and all my
menuoptions are stored in switchboard table. So whenever I add new
features to my application menu automatcially change. Some users of
my application are using package and new features is not included
until I create new package. I want this feature available to my
other users as soon as I am done with it. How can I check if form
or report or mudule is available in database before I call it?

Thanks.
 

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