Form placement in the window

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on my form that opens another form. I would like the second
form to open exactly beneath the button that was clicked to open it. What is
the code to make the second form open in relation to a control on the first
form?
Thanks for any help!
 
I have a button on my form that opens another form. I would like the second
form to open exactly beneath the button that was clicked to open it. What is
the code to make the second form open in relation to a control on the first
form?
Thanks for any help!



Code the Click event of the button (All on one line):

OpenSmall Me.ActiveControl.Left & "," & Me.ActiveControl.Top +
Me.ActiveControl.Height + Me.FormHeader.Height + 1440

Add a new sub to the form's code module

Public Sub OpenSmall(position As String)
DoCmd.OpenForm "frmFormName", , , , , acDialog, position
End Sub

If you don't wish to open the form in dialog, omit acDialog but retain
the comma.

You may have to adjust the +1440 to position the form a bit higher or
lower.
 
Thanks for the reply, Fred.
Don't I need some code in the second form to capture the "OpenArgs" numbers?
I'm not sure how to do that.
Appreciate the response....
 
Thanks for the reply, Fred.
Don't I need some code in the second form to capture the "OpenArgs" numbers?
I'm not sure how to do that.
Appreciate the response....

You're absolutely right. I just forgot to include it.

Private Sub Form_Load()
DoCmd.MoveSize Left(Me.OpenArgs, InStr(Me.OpenArgs, ",") - 1),
Mid(Me.OpenArgs, InStr(Me.OpenArgs, ",") + 1)

End Sub

Th DoCmd etc... should be all on one line
 
See:
http://www.lebans.com/openform.htm

A97OpenFormRelativeToControl.zip is an MDB showing how to open a second Form
relative to a control on the parent Form.

Version 1.5

Onno Willems added logic to support controls on TAB pages. Fixed logic Bug
for LEFT setting..



Version 1.4

Added logic to handle form's with their Popup property set to True. Added
support for the following positions relative to the specified control.

' 0 = Underneath
' 1 = On Top
' 2 = Right Side
' 3 = Left Side
' 4 = Bottom Right Hand Corner


Version 1.3

First release


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thank you, Fred & Stephen!!
I hope the users of this newsgroup appreciate how lucky we are to have
experts like you to answer questions!! Thanks a lot!
 
Stephen,
I used your example module and it works fantastically!!!
Thank you SO much! You are an awsome programmer!!
 
Back
Top