Results 1 to 10 of 10
  1. #1
    Join Date
    May 2007
    Posts
    12

    Question Unanswered: Max and Min a number of Forms via VBA

    I have a project where I have a number of forms I am using. There are
    3 forms that, information wise, tie to each other. What I would like to do
    is the following
    1. From main menu choose any one of the 3 forms (This I have done)
    2. When in the selected form go to any of the other 2 forms (I have
    buttons on bottom of each form to do this.
    Form1 - Button - Open Form 2, Form 3
    Form2 - Button - Open Form 1, Form 3
    Form3 - Button - Open Form 1, Form 2
    so for no problems... here is where I need help
    When the user is in form 1 (or 2 or 3) and wants to goto the other
    forms I donot want to close the form just minimize or hide it while they
    work on the other form and not Save any data (to save they must
    actually close the form by selecting Close/Save button on the form)
    this way they can work on 3 forms at once. So what I want is
    a If statement saying . If the form is already open and minimize then
    max it. If it is not open then Open the form based on the arg passed from
    the form you were in so your on the same information as the other form(s).

    I do know about the syscmd to check that status of a form if it is open or not
    but the problem lies in how do you Max or Min a specific form. or make that
    form active so you can jumb from form to form.
    hope this is clear as mud .. Thanks in advanc for any help.

  2. #2
    Join Date
    Aug 2006
    Posts
    559
    You can use:

    Code:
    DoCmd.Minimize ' minimize form
    DoCmd.OpenForm "formname"
    DoCmd.Close, acForm "YourFormName" 'close specific form
    You'd put that on each command button you have.

  3. #3
    Join Date
    May 2007
    Posts
    12
    Thanks .. but not sure I explained myself right...
    I got how to open a form and close a form but
    when I have 1 - 2 or 3 forms open and I select the button
    at the bottom of the form I want to
    1. Check to see if the form is already open
    if it is (it will be minimized) I want to restor it to normal size
    and the form Im in to minimize.
    if the form is not open (Check via syscmd saying open = false)
    I will then open the form using the cmd.open an pass arg to that
    for from the form im in.

    the reason is once the forms are open I want the user to beable to
    go to any of the 3 forms and change any information (when they
    jump from form to form (1 to 3, 3 to 2, 2 to 1 etc....) the information
    will not be saved untill the select the "Close/Save" button.
    If I put the docmd.close in the button it will save the data. If I do
    a close with out saving any information they have put in is lost.

    so basicily Im looking for a command like docmd.maximize "formname" but
    the docmd.maximize doesnt allow you to specify the formname.
    Again tkx for your help so for ..

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by Grafixx01
    DoCmd.Close, acForm "YourFormName" 'close specific form
    Should actually read
    Code:
    DoCmd.Close acForm, "YourFormName" 'close specific form

    In answer to the OP question:
    There is a function called IsLoaded in the Northwind sample database (look in the modules). Just copy it from there and paste it into a module in your database and you will be good to go.
    It can then be called via
    Code:
    If IsLoaded("MyForm") Then ...
    Not so sure about maximising by specifying form name...
    You could try opening it - this will give the form focus - and then try run the maximize command.
    HTH
    George
    Home | Blog

  5. #5
    Join Date
    May 2007
    Posts
    12
    Thanks again..
    I had something like that for the checking of the if form is open
    If SysCmd(acSysCmdGetObjectState, acForm, stDocName) <> 0 Then
    'Do your thing

    the only thing Im check is im going to type something in a field (Form_1)
    then click on Button (Form_2) and in the code put

    If SysCmd(acSysCmdGetObjectState, acForm, stDocName) <> 0 Then
    DoCmd.Minimize
    DoCmd.OpenForm "Form_2" 'Form is already open
    else
    DoCmd.Minimize
    DoCmd.OpenForm "Form_2, acNormal, , , , acWindowNormal, [Year_Selected] & ";" & [Parent_Info_Selected] & ";" & [Partnership_Selected]

    then see if the information stays the same in the fields I changed when I jump
    from form to form .. if so this will do..
    Again thanks.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Let us know how it goes / your final solution wontcha buddy?
    George
    Home | Blog

  7. #7
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    I would suggest you hide the form you are leaving with Me.Visible = False. Then when you want to see a form that is already open, you set it's .Visible property to True.

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Just thinking out loud here but what would happen if instead of minimizing a window you opened the window as hidden?
    Code:
    DoCmd.OpenForm "MyFormName", , , , , acHidden
    I believe you can just issue another OpenForm command and it will restore the form
    Code:
    DoCmd.OpenForm "MyFormName"
    George
    Home | Blog

  9. #9
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    I believe that the issue of another open command might cause the existing information on the form to be saved to the database, which I believe was stated as something that should not happen until the user clicks a button.

  10. #10
    Join Date
    May 2007
    Posts
    12
    sorry I havent gotten back to you (started new job and its a little crazy)
    but the process of minimizing the form and doing an open seems to work
    so far. tkx.. got another question but ill send a new thread cause its on
    a different subject
    Thanks for your help and responce.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •