Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restoring a form to full size in VBA

Status
Not open for further replies.

InkyRich

Technical User
Aug 2, 2006
126
GB
Hello,
I am trying to restore a form that has been minimized previously, on the click of a button in another form.
Minimize was straightforward but restoring the form back to its original size is proving difficult.

I have tried the code
DoCmd.Maximize "FormName"
and
DoCmd.Maximize acForm "FormName"
and
DoCmd.Restore acForm "FormName"
etc.

Where is my syntax wrong?

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
try
Code:
docmd.SelectObject acForm,"formname" 
docmd.Maximize
 
Thanks pwise,
But this does not work. Any other suggestions?

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
How are ya InkyRich . . .

In the code provided by [blue]pwise[/blue], did you edit the following in [purple]purple[/purple]: [surprise]
Code:
[blue]docmd.SelectObject acForm,"[purple][B][I]FormName[/I][/B][/purple]"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hi AceMan1,
Yes I did, but it is worth mentioning that I am trying to restore a form to its original size (not necessarily Maximize) from within a click action of another form.

Is it possible I need to enter the full path e.g. [Forms]!{FormName]. etc...

This has been minimized in a previous click action and I just want to be able to bring the form back into play on clicking this button.

Any ideas?

This is such a simple task I cannot believe that it is causing me so much of a problem.

Regards

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
You may try something like this:
Forms![form name].SetFocus
DoCmd.Restore

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You can try like this. (Tried from a second form)
Code:
Private Sub Command1_Click()
    With DoCmd
        .SelectObject acForm, "frmFirst"
        .Minimize
    End With

End Sub

Private Sub Command2_Click()
    With DoCmd
        .SelectObject acForm, "frmFirst"
        .Restore
    End With
End Sub

But you need to make sure the "frmFist" is open already
Code:
If CurrentProject.AllForms("your form name here").IsLoaded Then ...

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Hi Abdulla,
Your code:
With DoCmd
.SelectObject acForm, "frmFirst"
.Restore
End With
... worked to restore the window, but now I have the problem that I cannot use any of the buttons on the form and get a beep each time I try to click.
Is there another line of code that I should have in to prevent this?

Thanks

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
Possibilty is that your form- from where you are calling this code- might have opened as modal (acDialog).


________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Hello again Abdulla,
Sorry to be a nuisance but the form just seems to hang, and I cannot do anything on the screen. It seem to be waiting for me.
This is the code for the whole event, can you see anything wrong?

Code:
Private Sub CmdOpenLogOn_Click()
Dim LogOnPwrdVar As String
Dim PwrdCheckVar As String

LogOnNameVar = Nz(Me.cboLogOnInput.Column(1))
LogOnPwrdVar = Nz(Me.cboLogOnInput.Column(3))
LogOnPosition = Nz(Me.cboLogOnInput.Column(2))

PwrdCheckVar = Me.txtPwrdInput

        If LogOnPwrdVar = PwrdCheckVar Then
            
            With DoCmd
                .SelectObject acForm, "FRMOPENINGSWITCHBOARD"
                .Restore
            End With
    
            DoCmd.Close acForm, "FRMLogOn"
            
        ElseIf LogOnPwrdVar <> PwrdCheckVar Then
                    Me.txtPwrdInput = ""
                    MsgBox "This password is incorrect - please re-enter", vbOKOnly, "Note!"
                    Me.txtPwrdInput.SetFocus
                    
        End If


End Sub

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
Try changing it like
Code:
Private Sub CmdOpenLogOn_Click()
    Dim LogOnPwrdVar As String
    Dim PwrdCheckVar As String

    LogOnNameVar = Nz(Me.cboLogOnInput.Column(1))
    LogOnPwrdVar = Nz(Me.cboLogOnInput.Column(3))
    LogOnPosition = Nz(Me.cboLogOnInput.Column(2))

    PwrdCheckVar = Me.txtPwrdInput

    If LogOnPwrdVar = PwrdCheckVar Then

        With DoCmd
            .SelectObject acForm, "FRMOPENINGSWITCHBOARD"
            .Restore
        End With

        DoCmd.Close acForm, "FRMLogOn"

    Else

        Me.txtPwrdInput = ""
        MsgBox "This password is incorrect - please re-enter", vbOKOnly, "Note!"
        Me.txtPwrdInput.SetFocus

    End If


End Sub
You may use Trim() to avoid spaces in the pwd


________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Did you try my suggestion ?
Forms![FrmOpeningSwitchBoard].SetFocus
DoCmd.Restore

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hello phv,
Yes I have tried your code, but it has the same result as that of Abdulla's in that the form opens ok but it seems to freeze. Looking at the properties is seems that the focus is still on the CmdOpenLogOn_Click() event.

Inky

A fool and his money are soon parted - so you might as well send it to me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top