Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / December 2005

Tip: Looking for answers? Try searching our database.

if form is open then

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rivers - 31 Dec 2005 00:01 GMT
when i close a form without the previous form still open it brings up an
error and asks the user to debug is there an if statement that when the user
closes the original form that checks to see if the secondary form is still
open and closes it down  

pseudo

if extra = open then
close Extra form
else
close main

any help would be great
Dale Fye - 31 Dec 2005 01:32 GMT
Rivers,

I have a function that returns a boolean value if a form is loaded.  It
looks something like:

Public Function Isloaded(FormName As String) As Boolean

   Dim intLoop As Integer

   Isloaded = False

   If Forms.Count = 0 Then
       Exit Function
   Else
       For intLoop = 0 To Forms.Count - 1

           If Forms.Item(intLoop).Name = FormName Then
               Isloaded = True
               Exit Function
           End If
       Next
   End If

End Function

To use this in your code, you would do something like:

If isloaded("Extra") then
   docmd.close acform, "Extra"
Else
   docmd.close acform, "Main"
Endif

HTH
Dale

> when i close a form without the previous form still open it brings up an
> error and asks the user to debug is there an if statement that when the
[quoted text clipped - 10 lines]
>
> any help would be great
rivers - 31 Dec 2005 03:25 GMT
heres the code it aint beutiful its a bit of a hack job
If IsLoaded([HelpDesk_00Start Query]) Then
   Forms![HelpDesk_00Start Query].ExtrainfoButt.Visible = True
   Forms![HelpDesk_00Start Query].ExtraInfoID = Forms![HelpDesk_02Extra
Information].ExtraInfoID
   DoCmd.Close
Else
   DoCmd.Close
End If
this code is on another form called extrainf in a close button

> Rivers,
>
[quoted text clipped - 46 lines]
> >
> > any help would be great
fredg - 31 Dec 2005 04:53 GMT
> when i close a form without the previous form still open it brings up an
> error and asks the user to debug is there an if statement that when the user
[quoted text clipped - 9 lines]
>
> any help would be great

What version of Access?
Access 2000 or newer?

If Not CurrentProject.AllForms("FormA").IsLoaded Then
   Do something here
Else
    Do something else
End If

In Access 97, copy this function (from the Northwind.mdb sample
database) into a module:

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or
Datasheet view.

   Const conObjStateClosed = 0
   Const conDesignView = 0

   If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
       If Forms(strFormName).CurrentView <> conDesignView Then
           IsLoaded = True
       End If
   End If
End Function

Then code some event:
If Not IsLoaded("FormA") Then
   Do this
Else
   Do that
End if
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.