• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

Remember Form Screen Position

Good afternoon all,

I am using Access2003.  I have a form with the 'Pop Up" value set to true.  When the form is closed, the next time it is opened I want it to open in the same position it was in when it was closed.

Currently the Form will open depending on where it was saved in design view.  If I move the form, close it and then open it again it opens in the original location not where it was last moved to.

Looking forward to your responses.

Mavreich


0
Mavreich
Asked:
Mavreich
  • 4
  • 3
  • 3
  • +2
1 Solution
 
flavoCommented:
Add this to the forms code

Private Sub Form_Close()
DoCmd.Save acForm, Me.Name
End Sub

Dave
0
 
MavreichAuthor Commented:
Hi Flavo,

Thankyou for your speedy response.  It is much appreciated.

Your suggestion does not work for my scenario.  The form does not allow edits, adds or deletions.  It displays a treeview contol for display purposes.  

Thanking you again,  I look forward to an outcome..

Regards
Mavreich
0
 
peter57rCommented:
Hello Mavreich,

What you ask sounds so reasonable doesn't it. It should be simple!

Look here:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;143162


Pete
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jjafferrCommented:
Hi Mavreich,

Maybe on close you can save the Left and the Top positions in a Table,
then On open of the Form, retrieve these values and apply them.

I hope this helps.

jaffer
0
 
MavreichAuthor Commented:
Hi Pete,

Thanks for your response and the pointer.  It is appreciated.  I will look at it over the weekend  :(.

Regards
Mavreich
0
 
Rey Obrero (Capricorn1)Commented:

try this

Private Sub Form_Load()

'DoCmd.MoveSize Right, Down, Width, Height

'example
           DoCmd.MoveSize 4000, 3000            'this will move the 3" x 5 " form at the center of 21 inch monitor


end sub
0
 
peter57rCommented:
Hi Capricorn1,
The issue is not how to set the position but how to FIND the position.

JJafferr
There are no Top and Left properties for a form (or any other positional properties)
It would be a piece of cake if there were.

Pete
0
 
Rey Obrero (Capricorn1)Commented:
peter57r,
i need more coffee!!!  zzzzz

rey;-)
0
 
peter57rCommented:
Why?
Isn't life so much better when it's all fuzzy?

Pete
0
 
Rey Obrero (Capricorn1)Commented:
I think it depends in the situation you are in.
Sometimes it makes life more exciting.

rey;-)
0
 
MavreichAuthor Commented:
Hi all,

I never fails to amaze me how great this forum is.  I really appreciate all the help.  You would think that for such a simple thing as remember form position that there would be a simple solution.  Alas this appears not to be so.

If there is a solution I look forward to it.  In the mean time I am going to allow the user to minimise the form.  Not the solution I want but good enough as a stop gap measure.

I am still investigating the link supplied by pete.

Regards
Mavreich
0
 
jjafferrCommented:
Peter, this is copied from http://www.mvps.org/access/forms/frm0042.htm

 Forms: Move and Resize form windows from code
 Author(s)
Nicole Calinoiu
 
 
   Often times, it's necessary to open forms in specified locations and size them to a custom size. Windows API are the most convenient way of doing this, but the converting between the different coordinate systems can be a pain.

      Download clFormWindows.Bas

    This Class Module hides the API functions and provides generic methods to move and size your forms. The class, once imported in your application, can be used in in a couple of ways.

    1. To align the tops of two forms (at the position of the topmost form):

'********** Code Start ************
Public Sub AlignTops(ByRef frmA As Form, ByRef frmB As Form)
  Dim fwA As New clFormWindow, fwB As New clFormWindow
  fwA.hwnd = frmA.hwnd
  fwB.hwnd = frmB.hwnd
  If fwA.Top < fwB.Top Then
    fwB.Top = fwA.Top
  Else
    fwA.Top = fwB.Top
  End If
 
  Set fwA = Nothing
  Set fwB = Nothing
End Sub
'********** Code End  ************
    2. To move a form to the top right corner of the Access window:

'********** Code Start ************
Public Sub MoveToTopRight(ByVal strFormName As String)
  Dim fwForm As New clFormWindow
  Const SMALL_OFFSET = 5  'Used to position window slightly _
                      away from the Access MDI window border _
                          in order to avoid appearance of the Access _
                          window vertical scroll bar.
  With fwForm
    .hwnd = Forms(strFormName).hwnd
    .Top = .Parent.Top
    .Left = .Parent.Width - .Width - SMALL_OFFSET
  End With
  Set fwForm = Nothing
End Sub
'********** Code End ************
 
So I guess playing with this code would get the position wanted,
and On Close of the Form,
we have to save the position, Right?
0
 
MavreichAuthor Commented:
Hi all,

Thankyou all for your responses.  As always it is appreciated.  I have in the end abandoned this idea of saving the forms screen position.  However as Pete's linkwas the one I spent the most time on I have awared the points to Pete.

If this does not suit those of you who alos gave your valuable help please let me know.

Thanks again.

Mavreich
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now