×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Returning to the correct form!

Returning to the correct form!

Returning to the correct form!

(OP)
Okay where do I begin.

Right I have a form, called Customers, which is used to maintain a table of Known Customers/People of a company.

I have two forms, each of which need to run the Customers form, but before it does the calling form's visible property is set to false.  Once the customer form is closed I need to make the calling form visible again.

What I need is a section of code to do the following algorithm.

IF Invoice_form = present and invisible THEN
   Close Customer Form
   Set Invoice_form.visble = true
else
   Close customer Form
   set Main_Menu_Form.visible = true
endif

Thanks for any help I recieve.

Shane Brennan

Shane Brennan
brennans@tcat.ac.uk

RE: Returning to the correct form!

Copy and paste the following function into a module:

==========

Function IsLoaded(ByVal strFormName As String) As Boolean
    'Purpose: Determines if a given form is loaded
    'If IsLoaded("FormName") then ...
    
    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

==========

Now copy this code to the OnClose event of your customer form:

==========

Private Sub Form_Close()
   If IsLoaded("Main_Menu_Form") Then Forms!Main_Menu_Form.Visible = True
   If IsLoaded("Invoice_Form) Then Forms!Invoice_Form.Visible = True
   Docmd.Close acForm, "Customers"
End Sub

Jim Lunde
compugeeks@hotmail.com
CompuGEEKS
Custom Application Development

RE: Returning to the correct form!

For the simle case of two 'parents' supporting one child, the above is o.k.  If you expand the system (and what system doesn't expand?), it becomes easier to maintain a "list" of forms in the order of opening and just return to the previous.  Another option for the 'few' forms is just to place the name of the callling form in a global variable, and use the global var as the form to return to.

RE: Returning to the correct form!

Or save a little memory ("no one will ever need more than 640K") and pass Me.Name to the routine that will make Me visible when it closes.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close