Solved

Remember Form Screen Position

Posted on 2004-09-09
13
375 Views
Last Modified: 2008-03-17
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
Comment
Question by:Mavreich
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 12023585
Add this to the forms code

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

Dave
0
 
LVL 2

Author Comment

by:Mavreich
ID: 12023618
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
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 12024475
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 27

Expert Comment

by:jjafferr
ID: 12025022
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
 
LVL 2

Author Comment

by:Mavreich
ID: 12025026
Hi Pete,

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

Regards
Mavreich
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12025960

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
 
LVL 77

Expert Comment

by:peter57r
ID: 12026149
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12026261
peter57r,
i need more coffee!!!  zzzzz

rey;-)
0
 
LVL 77

Expert Comment

by:peter57r
ID: 12026293
Why?
Isn't life so much better when it's all fuzzy?

Pete
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12026378
I think it depends in the situation you are in.
Sometimes it makes life more exciting.

rey;-)
0
 
LVL 2

Author Comment

by:Mavreich
ID: 12031616
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
 
LVL 27

Expert Comment

by:jjafferr
ID: 12036903
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
 
LVL 2

Author Comment

by:Mavreich
ID: 12640592
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question