Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: MoveSize not working as expected

Geek News

MoveSize not working as expected
Dale Fye 11/26/2008 6:21:01 PM
I'm trying to open a form directly over the top of another form. I'm doing
this using the following code in the forms Load event:

If IsLoaded("frm_LD_Comments") Then
Set frm = Forms("frm_ld_Comments")
DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
frm.WindowWidth, frm.WindowHeight
Set frm = Nothing
End If

What I was expecting is that the new form would open, and then reposition
over the top of frm_LD_Comments. but it is actually getting positioned about
1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is causing
this?

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.

Re: MoveSize not working as expected
John Spencer <spencer[ at ]chpdm.edu> 11/26/2008 6:45:06 PM
Which form is the active form at this point?

You may need to wait until after the form is loaded for it to be the active form.

AS a test try moving the code to the Current Event of the form. If that works
then you can dim a static variable in the event and check to see if it has
been set or not.

Static iCount as Long

If iCount = 0 then
iCount = 1
'do your movesize stuff here
End if


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Dale Fye wrote:
[Quoted Text]
> I'm trying to open a form directly over the top of another form. I'm doing
> this using the following code in the forms Load event:
>
> If IsLoaded("frm_LD_Comments") Then
> Set frm = Forms("frm_ld_Comments")
> DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
> frm.WindowWidth, frm.WindowHeight
> Set frm = Nothing
> End If
>
> What I was expecting is that the new form would open, and then reposition
> over the top of frm_LD_Comments. but it is actually getting positioned about
> 1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is causing
> this?
>
Re: MoveSize not working as expected
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> 11/26/2008 7:02:44 PM
"Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
news:0EC8E927-CA7F-4B85-8DA7-1C06486D9DB6[ at ]microsoft.com...
[Quoted Text]
> I'm trying to open a form directly over the top of another form. I'm
> doing
> this using the following code in the forms Load event:
>
> If IsLoaded("frm_LD_Comments") Then
> Set frm = Forms("frm_ld_Comments")
> DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
> frm.WindowWidth, frm.WindowHeight
> Set frm = Nothing
> End If
>
> What I was expecting is that the new form would open, and then reposition
> over the top of frm_LD_Comments. but it is actually getting positioned
> about
> 1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is
> causing
> this?

Is this form (the one you're opening, with the code above) a PopUp form, by
any chance? Or opened in dialog mode? In such cases, the form's parent is
the desktop (I think), and so the coordinates are all off.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Re: MoveSize not working as expected
Dale Fye 11/26/2008 7:05:04 PM
John,

I stuck a line (msgbox screen.activeform.name ) inside the IF/End If and it
indicates that the active form is frm_LD_Comments_Add, which is the form I'm
trying to reposition.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"John Spencer" wrote:

[Quoted Text]
> Which form is the active form at this point?
>
> You may need to wait until after the form is loaded for it to be the active form.
>
> AS a test try moving the code to the Current Event of the form. If that works
> then you can dim a static variable in the event and check to see if it has
> been set or not.
>
> Static iCount as Long
>
> If iCount = 0 then
> iCount = 1
> 'do your movesize stuff here
> End if
>
>
> John Spencer
> Access MVP 2002-2005, 2007-2008
> The Hilltop Institute
> University of Maryland Baltimore County
>
> Dale Fye wrote:
> > I'm trying to open a form directly over the top of another form. I'm doing
> > this using the following code in the forms Load event:
> >
> > If IsLoaded("frm_LD_Comments") Then
> > Set frm = Forms("frm_ld_Comments")
> > DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
> > frm.WindowWidth, frm.WindowHeight
> > Set frm = Nothing
> > End If
> >
> > What I was expecting is that the new form would open, and then reposition
> > over the top of frm_LD_Comments. but it is actually getting positioned about
> > 1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is causing
> > this?
> >
>
Re: MoveSize not working as expected
Dale Fye 11/26/2008 7:43:01 PM
Dirk,

Yes, it is being opened in acDialog mode.

It's not a big deal to add a couple of offsets, I was just wondering whether
anyone knew why this was occuring.

I would normally just hide the form that I'm attempting to overlap, but it
was opened in dialog mode as well, and hiding it would allow the code (which
follows the OpenForm method on the main form) to continue processing.

Thanks for the info.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"Dirk Goldgar" wrote:

[Quoted Text]
> "Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
> news:0EC8E927-CA7F-4B85-8DA7-1C06486D9DB6[ at ]microsoft.com...
> > I'm trying to open a form directly over the top of another form. I'm
> > doing
> > this using the following code in the forms Load event:
> >
> > If IsLoaded("frm_LD_Comments") Then
> > Set frm = Forms("frm_ld_Comments")
> > DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
> > frm.WindowWidth, frm.WindowHeight
> > Set frm = Nothing
> > End If
> >
> > What I was expecting is that the new form would open, and then reposition
> > over the top of frm_LD_Comments. but it is actually getting positioned
> > about
> > 1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is
> > causing
> > this?
>
> Is this form (the one you're opening, with the code above) a PopUp form, by
> any chance? Or opened in dialog mode? In such cases, the form's parent is
> the desktop (I think), and so the coordinates are all off.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
Re: MoveSize not working as expected
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> 11/26/2008 8:05:37 PM
"Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
news:9D625001-1B8E-43A9-9128-65D51C382428[ at ]microsoft.com...
[Quoted Text]
> Dirk,
>
> Yes, it is being opened in acDialog mode.
>
> It's not a big deal to add a couple of offsets, I was just wondering
> whether
> anyone knew why this was occuring.
>
> I would normally just hide the form that I'm attempting to overlap, but it
> was opened in dialog mode as well, and hiding it would allow the code
> (which
> follows the OpenForm method on the main form) to continue processing.


You may be able to use Nicole Calinoiu's FormWindow class to control this:

http://www.mvps.org/access/forms/frm0042.htm
Forms: Move and Resize form windows from code

I'm not sure, but I wouldn't be at all surprised. I believe that class uses
API calls to get the parent window's coordinates.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Re: MoveSize not working as expected
"Paul Shapiro" <paul[ at ]hideme.broadwayData.com> 11/26/2008 10:42:50 PM
I just wrote some code for a similar situation. The code runs in the form
which is initially open when the user double-clicks an item in a listbox. It
opens frmParticipant to show the details of that item. The newly-opened form
is moved to the top left corner of the Access window. I turn off the modal
property on the originally open form so the user can work with the new form.
Finally I move the original form to the bottom of the new form so the new
form is almost completely visible.

DoCmd.OpenForm FormName:=strForm
Set frmParticipant = Forms(strForm)
frmParticipant.Move Left:=0, Top:=0
Call frmParticipant.GoToRecord(lngParticipantID:=lngActorID,
lngEventID:=lngEventID)

'Allow the user to click on the newly-opened form
Me.Modal = False
'Me.MinMaxButtons = 1 'Show the minimize button (ONLY available in
design mode)
'Me.PopUp = False 'Can only be set in design mode.
'frmParticipant.SetFocus 'User might not know this (partly-covered) form
has focus

'Move this form out of the way
Me.Move Left:=Me.WindowLeft, Top:=frmParticipant.WindowTop +
frmParticipant.WindowHeight


"Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
news:9D625001-1B8E-43A9-9128-65D51C382428[ at ]microsoft.com...
[Quoted Text]
> Dirk,
>
> Yes, it is being opened in acDialog mode.
>
> It's not a big deal to add a couple of offsets, I was just wondering
> whether
> anyone knew why this was occuring.
>
> I would normally just hide the form that I'm attempting to overlap, but it
> was opened in dialog mode as well, and hiding it would allow the code
> (which
> follows the OpenForm method on the main form) to continue processing.
>
> Thanks for the info.
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "Dirk Goldgar" wrote:
>
>> "Dale Fye" <dale.fye[ at ]nospam.com> wrote in message
>> news:0EC8E927-CA7F-4B85-8DA7-1C06486D9DB6[ at ]microsoft.com...
>> > I'm trying to open a form directly over the top of another form. I'm
>> > doing
>> > this using the following code in the forms Load event:
>> >
>> > If IsLoaded("frm_LD_Comments") Then
>> > Set frm = Forms("frm_ld_Comments")
>> > DoCmd.MoveSize frm.WindowLeft, frm.WindowTop, _
>> > frm.WindowWidth, frm.WindowHeight
>> > Set frm = Nothing
>> > End If
>> >
>> > What I was expecting is that the new form would open, and then
>> > reposition
>> > over the top of frm_LD_Comments. but it is actually getting positioned
>> > about
>> > 1" higher and 1/2" to the left of frm_LD_Comments. Any ideas what is
>> > causing
>> > this?
>>
>> Is this form (the one you're opening, with the code above) a PopUp form,
>> by
>> any chance? Or opened in dialog mode? In such cases, the form's parent
>> is
>> the desktop (I think), and so the coordinates are all off.
>>
>> --
>> Dirk Goldgar, MS Access MVP
>> www.datagnostics.com
>>
>> (please reply to the newsgroup)
>>
>>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net