Keep form on Top.

Jackpotgee

Registered User.
Local time
Today, 22:00
Joined
Jun 7, 2007
Messages
27
Hi,

I have a large main data entry form which has a button on which opens a second smaller form. The Main form is still visible behind it.

I want the smaller form to remain on top even if the user clicks on the Main form in the background. - The only way the user should be able to get rid of the smaller form is to use the close button.

Currently -

I have a public boolean variable that is set to false when the small form is opened.

If the user clicks the close button on the second form then this varialbe is updated to True.

I then use the on deactivate event on the smaller form as below.
Code:
Private Sub Form_Deactivate()
On Error GoTo ErrorProc

If ClsFrm = True Then GoTo ExitProc Else
Forms!Frm_AddPartner!NewFirstName.SetFocus = True

ExitProc:
Exit Sub

ErrorProc:
MsgBox Err.Description
Resume ExitProc

End Sub

What is it i am doing wrong with the SetFocus method? - Is this the correct method to use?

Thanks in advance
 
What is it i am doing wrong with the SetFocus method? - Is this the correct method to use?

You can only SetFocus to a form if
  1. It has no controls that can receive focus
  2. All controls it has that can receive focus have been disabled

All you need to do, to fulfill your stated requirements, is to make your second form (the one to stay on top) a popup form! Goto Properties - Other and set Popup to Yes.
 
Wow thanks! works a treat! - how do i then disable the Main Form in the background so that none of the fields are selectable.

Do i have to do it field by field or is there a simpler method to disable the entire form in one go?
 
Why not just open the small form as modal using acDialog in the open code. It will require you do deal with that form and not let you click on any other form until you close it.
 
Again, Superb!

Thank you! cant believe it was that simple!
 
I thought, from his original post, that he wanted the user to be able to interact with the first form while keeping the second form on top! That's what I get for thinking! :D
 

Users who are viewing this thread

Back
Top Bottom