Changing Form properties when Form Inactive

R

Richard Harison

Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the properties of a
form when that form does not have the focus. Specifically- Master Menu is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is maximized Master
Menu is visible behind the new form, and I would like it minimized. I used
DoCmd.minimize in the deactivation event, but how do I get it re-maximized when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
G

Guest

Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.
 
R

Richard Harison

I am a little confused by your reply as to which form is which. Maybe you could
restate your solution using my real form names. In my app, when Access opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
lwells said:
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



Richard Harison said:
Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the properties of a
form when that form does not have the focus. Specifically- Master Menu is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is maximized Master
Menu is visible behind the new form, and I would like it minimized. I used
DoCmd.minimize in the deactivation event, but how do I get it re-maximized when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
G

Guest

Richard,

You have just seen one of the limitations by using a macro. Why not try to
code using VBA in your events with the example supplied.

On your [Master Menu] using the button that opens the form [Volunteers]
place this code in the On Click event. You will need to open the VBA editor
to paste this code in. Click on the elipse the three dots to the right (...)
once you place your cursor in the On Click field. Select Code Builder and
paste the code between the blue Private Sub and End Sub blocks. Normally the
cursor will already be there to paste the code below.

DoCmd.OpenForm "Volunteers", , , , , , Me.Form.Name

In the Open Event of your [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

Then in the Close Event of [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will accomplish what you are after without using a macro.



Richard Harison said:
I am a little confused by your reply as to which form is which. Maybe you could
restate your solution using my real form names. In my app, when Access opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
lwells said:
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



Richard Harison said:
Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the properties of a
form when that form does not have the focus. Specifically- Master Menu is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is maximized Master
Menu is visible behind the new form, and I would like it minimized. I used
DoCmd.minimize in the deactivation event, but how do I get it re-maximized when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
R

Richard Harison

LIKE A CHARM!
Many, Many Thanks
(Any thoughts on how to ditch the Database Window as well?)
(Amen! on limits of macros!!)

--
All the Best . . .
Richard Harison
lwells said:
Richard,

You have just seen one of the limitations by using a macro. Why not try to
code using VBA in your events with the example supplied.

On your [Master Menu] using the button that opens the form [Volunteers]
place this code in the On Click event. You will need to open the VBA editor
to paste this code in. Click on the elipse the three dots to the right (...)
once you place your cursor in the On Click field. Select Code Builder and
paste the code between the blue Private Sub and End Sub blocks. Normally the
cursor will already be there to paste the code below.

DoCmd.OpenForm "Volunteers", , , , , , Me.Form.Name

In the Open Event of your [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

Then in the Close Event of [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will accomplish what you are after without using a macro.



Richard Harison said:
I am a little confused by your reply as to which form is which. Maybe you could
restate your solution using my real form names. In my app, when Access opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
lwells said:
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



:

Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the
properties
of a
form when that form does not have the focus. Specifically- Master Menu is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is maximized Master
Menu is visible behind the new form, and I would like it minimized. I used
DoCmd.minimize in the deactivation event, but how do I get it
re-maximized
when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
G

Guest

Sure,
Go To Tools/StartUp and uncheck Display Database Window

Cheers

Richard Harison said:
LIKE A CHARM!
Many, Many Thanks
(Any thoughts on how to ditch the Database Window as well?)
(Amen! on limits of macros!!)

--
All the Best . . .
Richard Harison
lwells said:
Richard,

You have just seen one of the limitations by using a macro. Why not try to
code using VBA in your events with the example supplied.

On your [Master Menu] using the button that opens the form [Volunteers]
place this code in the On Click event. You will need to open the VBA editor
to paste this code in. Click on the elipse the three dots to the right (...)
once you place your cursor in the On Click field. Select Code Builder and
paste the code between the blue Private Sub and End Sub blocks. Normally the
cursor will already be there to paste the code below.

DoCmd.OpenForm "Volunteers", , , , , , Me.Form.Name

In the Open Event of your [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

Then in the Close Event of [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will accomplish what you are after without using a macro.



Richard Harison said:
I am a little confused by your reply as to which form is which. Maybe you could
restate your solution using my real form names. In my app, when Access opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



:

Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the properties
of a
form when that form does not have the focus. Specifically- Master Menu is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is maximized Master
Menu is visible behind the new form, and I would like it minimized. I used
DoCmd.minimize in the deactivation event, but how do I get it re-maximized
when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
R

Richard Harison

Yeah...I knew that...I meant "on the fly" as it were...making it
visible/invisible with the wave of a hand! Thanks

--
All the Best . . .
Richard Harison
lwells said:
Sure,
Go To Tools/StartUp and uncheck Display Database Window

Cheers

Richard Harison said:
LIKE A CHARM!
Many, Many Thanks
(Any thoughts on how to ditch the Database Window as well?)
(Amen! on limits of macros!!)

--
All the Best . . .
Richard Harison
lwells said:
Richard,

You have just seen one of the limitations by using a macro. Why not try to
code using VBA in your events with the example supplied.

On your [Master Menu] using the button that opens the form [Volunteers]
place this code in the On Click event. You will need to open the VBA editor
to paste this code in. Click on the elipse the three dots to the right (...)
once you place your cursor in the On Click field. Select Code Builder and
paste the code between the blue Private Sub and End Sub blocks. Normally the
cursor will already be there to paste the code below.

DoCmd.OpenForm "Volunteers", , , , , , Me.Form.Name

In the Open Event of your [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

Then in the Close Event of [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will accomplish what you are after without using a macro.



:

I am a little confused by your reply as to which form is which. Maybe
you
could
restate your solution using my real form names. In my app, when Access opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



:

Hello!
My database has a Master Menu (not created with a wizard) There are command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the properties
of a
form when that form does not have the focus. Specifically- Master
Menu
is
maximized upon activation, but when Master Menu transfers focus to another
form, I want that form windowed--not maximized. Problem is
maximized
Master
Menu is visible behind the new form, and I would like it minimized.
I
used
DoCmd.minimize in the deactivation event, but how do I get it re-maximized
when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
G

Guest

Just for fun,

Create a command button on a form and give it the name cmdHide and the
caption of Hide DB. In the On Click event paste this code:

Private Sub cmdHide_Click()
If Me.cmdHide.Caption = "Hide DB" Then
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
Me.cmdHide.Caption = "UnHide DB"
ElseIf Me.cmdHide.Caption = "UnHide DB" Then
DoCmd.SelectObject acTable, , True
Me.cmdHide.Caption = "Hide DB"
Me.SetFocus
End If
End Sub

Now you can toggle showing or hiding the database window. You can probably
adapt the code anywhere you want pretty easily.

Cheers
Richard Harison said:
Yeah...I knew that...I meant "on the fly" as it were...making it
visible/invisible with the wave of a hand! Thanks

--
All the Best . . .
Richard Harison
lwells said:
Sure,
Go To Tools/StartUp and uncheck Display Database Window

Cheers

Richard Harison said:
LIKE A CHARM!
Many, Many Thanks
(Any thoughts on how to ditch the Database Window as well?)
(Amen! on limits of macros!!)

--
All the Best . . .
Richard Harison
Richard,

You have just seen one of the limitations by using a macro. Why not try to
code using VBA in your events with the example supplied.

On your [Master Menu] using the button that opens the form [Volunteers]
place this code in the On Click event. You will need to open the VBA editor
to paste this code in. Click on the elipse the three dots to the right (...)
once you place your cursor in the On Click field. Select Code Builder and
paste the code between the blue Private Sub and End Sub blocks. Normally the
cursor will already be there to paste the code below.

DoCmd.OpenForm "Volunteers", , , , , , Me.Form.Name

In the Open Event of your [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

Then in the Close Event of [Volunteers] form paste this code (VBA Editor
window)

If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will accomplish what you are after without using a macro.



:

I am a little confused by your reply as to which form is which. Maybe you
could
restate your solution using my real form names. In my app, when Access
opens,
the form [Master Menu] automatically appears maximized. A command button on
{Master Menu] calls, by macro (NOT VBA), the form [Volunteers], which is
displayed windowed, and [Master Menu] remains in background.
It just seems to me that VBA should be able to focus a form by tracing the
correct path, i.e. Forms![formname]....
Thanks for your help
--
All the Best . . .
Richard Harison
Richard,

I use the OpenArgs for this purpose in my application.

Try this, from you command button that opens your form add the last
argument
to your open form with Me.Form.Name

example:
DoCmd.OpenForm "OtherFormName", , , , , , Me.Form.Name

Then in the Open Event of the form that was opened place this code

If Not IsNull(Me.OpenArgs) Then
DoCmd.SelectObject acForm, Me.OpenArgs
DoCmd.RunCommand acCmdWindowHide
End If

This will hide your Main Menu form

Then in the close event place this code
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs
End If

This will reopen your Main Menu form when you close the form.



:

Hello!
My database has a Master Menu (not created with a wizard) There are
command
buttons to call other forms & reports. (I use macros for this)
I am trying to devise a way, using Visual Basic, to change the
properties
of a
form when that form does not have the focus. Specifically- Master Menu
is
maximized upon activation, but when Master Menu transfers focus to
another
form, I want that form windowed--not maximized. Problem is maximized
Master
Menu is visible behind the new form, and I would like it minimized. I
used
DoCmd.minimize in the deactivation event, but how do I get it
re-maximized
when
I close the new form? There must be a way to change the properties of a
non-active from in a VB routine called by another form. I tried:
Forms![Master Menu].windowstate=vbminimized
Got an error message. That was all I could think to do. Please help!

All the Best . . .
Richard Harison
 
R

Richard Harison

It was fun! I loved the way you used changing the caption not only to show
which state the button was in but which logic to trigger. Clever!
My visuals look a lot better now, and since the database is for a social service
organization, it was in a good cause! Thanks again!!
--
All the Best . . .
Richard Harison
lwells said:
Just for fun,

Create a command button on a form and give it the name cmdHide and the
caption of Hide DB. In the On Click event paste this code:

Private Sub cmdHide_Click()
If Me.cmdHide.Caption = "Hide DB" Then
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
Me.cmdHide.Caption = "UnHide DB"
ElseIf Me.cmdHide.Caption = "UnHide DB" Then
DoCmd.SelectObject acTable, , True
Me.cmdHide.Caption = "Hide DB"
Me.SetFocus
End If
End Sub

Now you can toggle showing or hiding the database window. You can probably
adapt the code anywhere you want pretty easily.

Cheers
~~~snip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top