Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Posts
    32

    Unanswered: displaying forms

    Hello,

    Is there any property to set how the form to be displayed in access?

    I want to display some forms maximized and some forms not.

    Please help me in this matter.

    Thanking you all

    Krishna

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb Re: displaying forms

    Originally posted by annam
    Hello,

    Is there any property to set how the form to be displayed in access?

    I want to display some forms maximized and some forms not.

    Please help me in this matter.

    Thanking you all

    Krishna
    You can use
    DoCmd.OpenForm "yourFormName" ' 2 Open ur form
    DoCmd.Minimize ' 2 minimize it

    DoCmd.OpenForm "yourFormName" ' 2 Open ur form
    DoCmd.Maximize ' 2 maximize it

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487

    Re: displaying forms

    The DoCmd.Maximize and DoCmd.Minimize work great for manipilating your form's window state and is probably the easiest way to accomplish what you want. But it may not always give the effect you desire unless properly utilize. Generally, the DoCmd.Maximize command will maximize ALL the forms within the ACCESS parent window. Not really a problem at this point since the form you opened is covering all the other forms. The problem arises when you close this opened, maximized form to find that your start form is now maximized as well. For example:

    - FormA opens FormB and in the Open event of FormB the statement you have DoCmd.Maximize.
    - FormB opens and the window expands into the maximized state. This is exactly what you want Subsequently though, so do all your other forms.
    - "No problem you think",..."I will just place the DoCmd.Minimize into the Activate event of 'FormA' ". Hmmmm...still maximized.

    The way around this little problem is to place the DoCmd.Minimize statement into the Close event of FormB.

    For example:
    FormA opens FormB and we want FormB to be Maximized. We want FormA to display its' normal window state when FormB is closed.

    [code]
    Private Sub Command1_Click()
    'Open FormB
    DoCmd.OpenForm "FormB"
    End Sub

    Code:
    Private Sub FormB_Open(Cancel As Integer)
        'Maximize FormB
        DoCmd.Maximize
    End Sub
    
    Private Sub FormB_Close()
        'Bring Things back to normal
        DoCmd.Minimize
    End Sub
    All this can also be accomplished using a Windows API function as well. In particular, the 'ShowWindow' function. Basicly , it does the same thing as the DoCmd.Maximize/Minimize commands but some what faster.

    To use the ShowWindow API function, place the following into the declaration section of a code module:

    Code:
    Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal _
             nCmdShow As Long) As Long
    
    Public Const SW_MAXIMIZE = 3
    Public Const SW_MINIMIZE = 2
    Public Const SW_SHOWNORMAL = 1
    Although not needed for our purpose here now, I've also added the 'IsZoomed' API function here as well. This function can tell you if a specific form is actually maximized.

    Now...in the FormB:

    Code:
    Private Sub FormB_Open(Cancel As Integer)
        'Maximize FormB
        ShowWindow Me.hWnd, SW_MAXIMIZE
        'This is an example of how you might use the IsZoomed function
        MsgBox "Is FormB Maximized (True Or False)?  =  " & CBool(IsZoomed(Me.hWnd))
    End Sub
    
    Private Sub FormB_Close()
        'Bring things back to normal
        ShowWindow Me.hWnd, SW_SHOWNORMAL
    End Sub
    Hope this helps in some little way.

  4. #4
    Join Date
    Nov 2003
    Posts
    32
    Thanks for your suggestion.

    I did the way you specified. The window is getting completely minimized. I want the window to be in normal form.

    Is there any way to do that?

    Please help me.

  5. #5
    Join Date
    Mar 2003
    Posts
    130
    Code:
    Private Sub Form_Load()
        
        DoCmd.Maximize
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        
        DoCmd.Restore
        
    End Sub

  6. #6
    Join Date
    Jan 2004
    Posts
    64
    How can I minimize one form as it open another form?
    This is the command button that opens "Calls" form. When I open the calls form I want my original form (where the open calls button is located) to minimize (not close).

    Private Sub Command111_Click()
    On Error GoTo Err_Calls_Click
    If IsNull(Me![ContactID]) Then
    MsgBox "Enter contact information before making a call."
    Else
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.OpenForm "Calls"
    End If

    Exit_Calls_Click:
    Exit Sub

    Err_Calls_Click:
    MsgBox Err.Description
    End Sub

    Thanks.

  7. #7
    Join Date
    Nov 2003
    Posts
    1,487
    bsarman,

    Well...a simple way is not to minimize it at all but instead, hide it (make the form invisible). Then, before the second form closes, make it visible again.

    Let us say the code you posted is contained on a form named MainForm (as you had indicated) and from this code you are going to open and display a form named Calls. Your code would appear in MainForm as follows:

    Code:
    Private Sub Command111_Click()
       On Error GoTo Err_Calls_Click
       If IsNull(Me![ContactID]) Then
           MsgBox "Enter contact information before making a call."
       Else
           'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
           'The DoMenuItem code line above has basically become 
           'redundant. Use the line provided below instead.
           DoCmd.RunCommand acCmdSaveRecord
           'The line below makes 'MainForm' Invisible.
           Me.Visible = False
           DoCmd.OpenForm "Calls"
       End If
    
    Exit_Calls_Click:
       Exit Sub
    
    Err_Calls_Click:
       MsgBox Err.Description
       'If there was an error then make MainForm Visible again.
       Me.Visible = True
    End Sub
    Now...in the OnClose event located in the Calls form, copy and paste the code line below:

    Code:
       [Forms]![MainForm].Visible = True
    where MainForm must be the actual name of the form that opened the Calls form.

    This is just one way....

    Hope it helps a little

  8. #8
    Join Date
    Jan 2004
    Posts
    64
    Your code worked great. Thanks a lot, I really appreciate your sharing the knowledge. Have a great weekend.

Posting Permissions

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