The order of forms

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

After choices are made on the switchboard form, I really want it to stay in the background, the bottom form shown while the rest of the database forms are accessed. How can I do that?
 
I've seen a few ways to do that. The first is to open
each form modal, that way you can't get to the switchboard.

The other is to hide the switchboard, then unhide it when
the desired form closes.

You could also: On the close event of each form:

Forms("Switchboard").Visible = Not Forms.Count > 1

Chris

-----Original Message-----
After choices are made on the switchboard form, I really
want it to stay in the background, the bottom form shown
while the rest of the database forms are accessed. How
can I do that?
 
Hi,





If you want to the switchboard to remain visible and below all of the other forms you can do the following





1. Create a module containing the following code



Option Compare Database

Option Explicit



Public Declare Function SetWindowPos Lib "user32" _

(ByVal hwnd As Long, _

ByVal hwndInsertAfter As Long, _

ByVal x As Long, _

ByVal y As Long, _

ByVal cx As Long, _

ByVal cy As Long, _

ByVal wFlags As Long) As Long



Public Const HWND_BOTTOM = 1



Public Const SWP_NOSIZE = &H1

Public Const SWP_NOMOVE = &H2

Public Const SWP_NOACTIVATE = &H10



Public Function PushFormToBottom(ByVal frm As Form) As Long

'Non-zero value indicates success

PushFormToBottom = SetWindowPos( _

frm.hwnd, _

HWND_BOTTOM, _

0, _

0, _

0, _

0, _

SWP_NOSIZE Or _

SWP_NOMOVE Or _

SWP_NOACTIVATE)

End Function





2. Create a Form_Activated event procedure for each form that can be opened from the

Switchboard. The Form_Activated event procedure should contain the following code



Dim frm As Form



Dim status As Long





Set frm = Forms("Put the name of your switchboard here")



'Non-zero status indicates success

status = PushFormToBottom (frm.hwnd)





Wayne Pearson



After choices are made on the switchboard form, I really want it to stay in the background, the bottom form shown while the rest of the database forms are accessed. How can I do that?
 
Chris,

Thanks for the idea. I had tried modal but the point wasn't really to
prevent other forms from being available, more to really push the
switchboard to the background; for some reason it keeps jumping in front of
other forms when they are opened.

I'll take a look at the code and see how it goes.
 
Wayne

Thanks for such an comprehensive solution. I will definitely try this out.

--
Karen
Hi,





If you want to the switchboard to remain visible and below all of the other forms you can do the following





1. Create a module containing the following code



Option Compare Database

Option Explicit



Public Declare Function SetWindowPos Lib "user32" _

(ByVal hwnd As Long, _

ByVal hwndInsertAfter As Long, _

ByVal x As Long, _

ByVal y As Long, _

ByVal cx As Long, _

ByVal cy As Long, _

ByVal wFlags As Long) As Long



Public Const HWND_BOTTOM = 1



Public Const SWP_NOSIZE = &H1

Public Const SWP_NOMOVE = &H2

Public Const SWP_NOACTIVATE = &H10



Public Function PushFormToBottom(ByVal frm As Form) As Long

'Non-zero value indicates success

PushFormToBottom = SetWindowPos( _

frm.hwnd, _

HWND_BOTTOM, _

0, _

0, _

0, _

0, _

SWP_NOSIZE Or _

SWP_NOMOVE Or _

SWP_NOACTIVATE)

End Function





2. Create a Form_Activated event procedure for each form that can be opened from the

Switchboard. The Form_Activated event procedure should contain the following code



Dim frm As Form



Dim status As Long





Set frm = Forms("Put the name of your switchboard here")



'Non-zero status indicates success

status = PushFormToBottom (frm.hwnd)





Wayne Pearson



After choices are made on the switchboard form, I really want it to stay in the background, the bottom form shown while the rest of the database forms are accessed. How can I do that?
 
Karen,


There's an error in the Form_Activate code I suggested

The line


status = PushFormToBottom (frm.hwnd)


should be replaced by


status = PushFormToBottom (frm)

Set frm = Nothing


Sorry about that


Wayne Pearson

Wayne

Thanks for such an comprehensive solution. I will definitely try this out.

--
Karen
Hi,





If you want to the switchboard to remain visible and below all of the other forms you can do the following





1. Create a module containing the following code



Option Compare Database

Option Explicit



Public Declare Function SetWindowPos Lib "user32" _

(ByVal hwnd As Long, _

ByVal hwndInsertAfter As Long, _

ByVal x As Long, _

ByVal y As Long, _

ByVal cx As Long, _

ByVal cy As Long, _

ByVal wFlags As Long) As Long



Public Const HWND_BOTTOM = 1



Public Const SWP_NOSIZE = &H1

Public Const SWP_NOMOVE = &H2

Public Const SWP_NOACTIVATE = &H10



Public Function PushFormToBottom(ByVal frm As Form) As Long

'Non-zero value indicates success

PushFormToBottom = SetWindowPos( _

frm.hwnd, _

HWND_BOTTOM, _

0, _

0, _

0, _

0, _

SWP_NOSIZE Or _

SWP_NOMOVE Or _

SWP_NOACTIVATE)

End Function





2. Create a Form_Activated event procedure for each form that can be opened from the

Switchboard. The Form_Activated event procedure should contain the following code



Dim frm As Form



Dim status As Long





Set frm = Forms("Put the name of your switchboard here")



'Non-zero status indicates success

status = PushFormToBottom (frm.hwnd)





Wayne Pearson



After choices are made on the switchboard form, I really want it to stay in the background, the bottom form shown while the rest of the database forms are accessed. How can I do that?
 
Back
Top