Position popup relative to records in detail section

D

DavidS

I have a main form with a detail section that has listing of database records
ordered by date. When I click a date record field control, I'd like to have
a popup form displayed to the right of this date control's position from the
detail section.

How do position the left and top placement for this popup window so it's
always relative to the location of the data control from the detail section?
Is this possible?
 
F

fredg

I have a main form with a detail section that has listing of database records
ordered by date. When I click a date record field control, I'd like to have
a popup form displayed to the right of this date control's position from the
detail section.

How do position the left and top placement for this popup window so it's
always relative to the location of the data control from the detail section?
Is this possible?

I would suggest the control's double-click event rather than upon
entry.
First add a sub procedure to the form's code sheet.
Watch out for word wrap.

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

2)
Then code the double-click event of the control:

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

Change the position of the form by changing the values passed to the
OpenSmall procedure.
Note: All measurements are in Twips, 1440 per inch.

3)
Code the Form's (the one you are opening) Load event:

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

End Sub

As written above, the form will open to the right of, and just
slightly below, the control.
 
D

DavidS

I'm not showing attributes .LEFT, .TOP, WIDTH, .RIGHT for ActiveControl of
the form.

You line OpenSmall Me.ActiveControl.Left,... .left is not defined for Access
forms
 
D

DavidS

The issue I have is basically if you have say 6 records in the detail section
- I'm NOT able to determine each record sets position relative to the detail
section itself.

If I depress and event for the control - On Mouse Move - for instance - I
will obtain positional values for x, y that are always bounded by the
control. IF I obtain position for first record - their same as nth record of
detail list.

Same applies with ActiveControl.Left / ActiveControl.Top - I'm always
getting 0, 0 - for first control of form - whether I'm on 1st record or nth
record. I would of thought their was a means to determine the mouse position
relative to the recordset - but I'm constantly receiving the same X, Y - or
left, top, irregardless of WHICH recordset I'm on.

Also - I have the same process / I open form - and want to change the size
in Form_Load relative to WHAT record I'm on - real issue is HOW TO GET
VARIABLE left, top positions from a detail section for the datasets that are
their - I've tried even API interface to Windows position functions - and I
can't seem to get anywhere but CONSTANT fixed values for .LEFT, .TOP always.

I hope this is explains the issue I have.
 
S

Stephen Lebans

Posting in CAPS is considered rude. I realize you may be fruistrated but
AFAIK there is no published solution for opening a form relative to a
control's position on a form set to Continuous view. You will have to
combine the functionality found in two different solutions posted on my
site.

For forms in single mode 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



Now, you will require the vertical offset from the top most visible row.
Have a look at:
http://www.lebans.com/conformscurcontrol.htm
or
The Seltop sample form here:
http://www.lebans.com/setgetsb.htm
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
F

fredg

The issue I have is basically if you have say 6 records in the detail section
- I'm NOT able to determine each record sets position relative to the detail
section itself.

If I depress and event for the control - On Mouse Move - for instance - I
will obtain positional values for x, y that are always bounded by the
control. IF I obtain position for first record - their same as nth record of
detail list.

Same applies with ActiveControl.Left / ActiveControl.Top - I'm always
getting 0, 0 - for first control of form - whether I'm on 1st record or nth
record. I would of thought their was a means to determine the mouse position
relative to the recordset - but I'm constantly receiving the same X, Y - or
left, top, irregardless of WHICH recordset I'm on.

Also - I have the same process / I open form - and want to change the size
in Form_Load relative to WHAT record I'm on - real issue is HOW TO GET
VARIABLE left, top positions from a detail section for the datasets that are
their - I've tried even API interface to Windows position functions - and I
can't seem to get anywhere but CONSTANT fixed values for .LEFT, .TOP always.

I hope this is explains the issue I have.

Where in your original post have you mentioned the words "continuous
form"? Or anything like "6 records in the detail section" which would
have tipped a potential responder off that you are not using a single
view form?

On a continuous view form, each control is the same, re-iterated many
times.

My solution will open a form just to the right of and just below,
whatever active control has been double clicked on a Single Form View
form, if that control's double-click event has been coded as
indicated.
 
D

DavidS

Intent was not to dispute your knowlege or solution - your advice and
response was appreciated. Just, I wasn't aware that "continuous" forms made
a difference with respect to the issue @ hand.

I'm using VBA since project initially used this and there are features of
access that are easier to develop with versus Visual C++ that I prefer.

Also - you did answer accurately the questions above - but I think if I put
my last response in the system - I might of NOT received any response at all.
Since I normally review "google" searches to see what "other" end-users have
experienced - and I "sensed" possibly no solution - since I was using class
structures built around API function calls to get ordinate positions that
weren't changing - I took this approach to see if others might confirm what I
was finding too.

Kind regards for prompt response and feedback, please don't take offense
either - just that I was getting frustrated using Access - and I am "crunched
for time" and really didn't want to write separate class structure to bypass
access.
 
D

DavidS

CAPS was not intentional. Actually, I sent the e-mail it appears at same
time when I received the first response from fredg.

Since this is NOT RTF - it's easier for me to have certain keywords stand
out with CAPS.

I apologize if anyone offended - intent was not to be negative to anyone.

Concerning your response - I actually researched this from "google" news
group sometime late last week. Yes, I actually downloaded modPositionWindow
too - and like this to clarify how to do this for form and popups.

Also, yes, I was @ the same point as you - HOW to figure out the vertical
offset from each of the datasets. I will review now your second hyperlink
and advise you what I find.

KIND REGARDS for assistance,
I couldn't get this proper without your help too and it's ALWAYS appreciated,
David
 
M

Marion Knight-Dixon

I have tried using the procedure below and my pop up form is ignoring the position of my main form. I have obviously coded something wrong but cannot see what. I have copied by coding below so hopefully you can see where I have not changed something I should have. My main form is frmstudent and the popup form is called frmpopup and the field I am using to double click from is StuDateOfBirth

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

(I have put in here the name of the popup form to be opened - is this correct?)

Private Sub StuDateOfBirth_DblClick(Cancel As Integer)
OpenSmall Me.ActiveControl.Left + Me.ActiveControl.Width & "," & Me.ActiveControl.Top + Me.ActiveControl.Height + Me.FormHeader.Height + 1440
End Sub

(This is my double click event from a form called frmstudent)

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

End Sub

(This is my on load coding for frmpopup

The popup form opens but regardless of where frmstudent is the form opens in the same place.

Any help is identifying what is probably a simple error gratefully appreciated.
 
W

Wolfgang Kais

Hello Marion.

Marion Knight-Dixonwrote:
I have tried using the procedure below and my pop up form is
ignoring the position of my main form. I have obviously coded
something wrong but cannot see what. I have copied by coding below
so hopefully you can see where I have not changed something I
should have. My main form is frmstudent and the popup form is
called frmpopup and the field I am using to double click from
is StuDateOfBirth

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

(I have put in here the name of the popup form to be opened - is
this correct?)

Yes, it is, and as you can see on your screen: it opens the popup.
Private Sub StuDateOfBirth_DblClick(Cancel As Integer)
OpenSmall Me.ActiveControl.Left + Me.ActiveControl.Width & "," & _
Me.ActiveControl.Top + Me.ActiveControl.Height + _
Me.FormHeader.Height + 1440
End Sub

(This is my double click event from a form called frmstudent)

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

(This is my on load coding for frmpopup)

The popup form opens but regardless of where frmstudent is the form
opens in the same place.

Any help is identifying what is probably a simple error gratefully
appreciated.

The position (Left, Top) of a control on a form does not change when
you move the form, they are relative to the left and top margins of
the form section.
You should try to add the forms left and top position:
Private Sub StuDateOfBirth_DblClick(Cancel As Integer)

OpenSmall Me.ActiveControl.Left + Me.ActiveControl.Width + _
Me.WindowLeft & "," & Me.ActiveControl.Top + _
Me.ActiveControl.Height + Me.FormHeader.Height + 1440 + _
Me.WindowTop
End Sub
 
E

efandango

David, care to enlighten me; can you code a pop-up form to match a control's
position on a continous form? if so, how was it done with the crown jewel?

I would love to have this incredibly useful functionality on my continuous
forms (are you listening Microsoft...)
 

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