Restore Form Position (Access 2010)

kirkm

Registered User.
Local time
Today, 14:31
Joined
Oct 30, 2008
Messages
1,257
There's a button on my Form which runs a query. When I close the query the Forms Top has moved up under the ribbon.
(Both Query and Form show as Full Screen)

I thought it'd be a simple matter of restoring the Forms Top value, but I can't find a Top Property.
Then things got worse... I'm now not sure what the Forms name is. In the VB Editor window is is called "Form_frmMain"
but in the LH Colum of Objects under "Forms" it's "frmMain". In design View the Property Sheet has no Name for the Form (although it's again shown as "frmMain" in the great area above the ribbon).

Why are the names different and how could I find/Restore the Forms Top position?
Thanks for any info.
 
Why open a query? Users should not interact with tables and queries, only forms and reports.

Form does not have Top property.

VBA editor prefixes form and report object names with Form_ or Report_. It's still the same form or report.

I never use full screen. If form is maximized, then I would expect it to be up next to the ribbon. If you want to provide db for analysis, follow instructions at bottom of my post.
 
Last edited:
I can't really answer why open a query, except that its what I want to do.
OK on "Form_" part, thanks.

Maybe someone else knows how I could restore the Form correctly after closing the query? The ribbon doesn't change, it stays in the same place, but the Form has moved up by about 1.5 inches.


It does come right if I click View- Design View, then View Form View.
 
I believe this project is just your personal project.?

Try using the Autocenter property of the form.
 
Hi. Not sure if this will help but have you considered using the Tabbed Documents window option?
 
Thanks to the replies. AutoCenter didn't change anything. Also tried Fit To Screen but no change there either. Tabbed Document was a good idea and keeps the right Form Size, but covers up some controls at the top of the Form. I could redesign it.. but ideally figuring out why it does this and fixing it would be better. Any other thoughts? Should I upload a demo as June suggests?
 
If you're saying that the form becomes maximized because of opening the query, then I'd try Restore on the form. Reads like you're using vba code and not macros, so DoCmd.Restore. You might need to give it the focus first, or make it the active window.
 
Yes it's VBA. Cam I detect the Close Event of the query? It's called by a button on the (main) Form.
Code:
Private Sub txtShow_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Dim MyQuery As QueryDef
    Dim sql As String

    <Build SQL string>
  
    Set MyQuery = CurrentDb.QueryDefs("zqryShow")
    MyQuery.sql = sql
    DoCmd.OpenQuery "zqryShow", acNormal, acEdit
    Set MyQuery = Nothing
   ' DoCmd.Restore
End If
End Sub
I tried docmd.Restore as above, but it didn't do what was wanted and is probably not in the right place.
If you can't set a Forms Top value in Properties how does Access know where to put it?
 
Yes it's VBA. Cam I detect the Close Event of the query? It's called by a button on the (main) Form.
Code:
Private Sub txtShow_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Dim MyQuery As QueryDef
    Dim sql As String

    <Build SQL string>
  
    Set MyQuery = CurrentDb.QueryDefs("zqryShow")
    MyQuery.sql = sql
    DoCmd.OpenQuery "zqryShow", acNormal, acEdit
    Set MyQuery = Nothing
   ' DoCmd.Restore
End If
End Sub
I tried docmd.Restore as above, but it didn't do what was wanted and is probably not in the right place.
If you can't set a Forms Top value in Properties how does Access know where to put it?
Hi. Yes, I think a sample/demo db would help figure out the problem. But, if you had a way to position the top of the form somewhere on the screen, where would you place this code? Which event would you use?
 
OK, let me try and get it prepared. As for where or event, as the Form loads to start with it (somehow?) just goes to the right place/size with (afaik), without anything I've done..

So just repeating that, or finding where it changes (and stopping it) would be what I'd do if I knew how.
 
OK, let me try and get it prepared. As for where or event, as the Form loads to start with it (somehow?) just goes to the right place/size with (afaik), without anything I've done..

So just repeating that, or finding where it changes (and stopping it) would be what I'd do if I knew how.

Hi. Okay. You can tell the form to position itself by using its Move method. But without seeing how your form or your users interact with the query, I can’t tell you exactly where to put the code to execute it. As you already know, queries don’t have events, that’s why we recommend using forms, in datasheet view to make them look like a query, if that’s the look you prefer.
 
Probably will require direct intervention on the part of the user, such as Detail.DblClick but none of this will really help if the form isn't being maximized. That hasn't been answered, AFAIK.
 
Probably will require direct intervention on the part of the user, such as Detail.DblClick but none of this will really help if the form isn't being maximized. That hasn't been answered, AFAIK.

I’m hoping to find the answer to all our questions once we can see the db in action.
 
Took a while but I managed a working example of the problem. Attached.
If you open frmMain, close the Nav Bar, that's how it should look. But if you run the query (Hit enter in the text box mid-screen above the sub form) the Form will move up under the ribbon after you close the query,

But now the really crazy thing... in my full version (trying different things to prepare the demo) I added a button to frmMain with code "Docmd.Maximize". I clicked it and nothing appeared to happen, but ever since the problem has gone away and the screen remains the correct size after running the query. And opening/closing the mdb.

But it would still be good to know what's going on in the demo, perhaps the other will play up again...
Thanks very much for looking. You guys are great helping out !
 

Attachments

Took a while but I managed a working example of the problem. Attached.
If you open frmMain, close the Nav Bar, that's how it should look. But if you run the query (Hit enter in the text box mid-screen above the sub form) the Form will move up under the ribbon after you close the query,

But now the really crazy thing... in my full version (trying different things to prepare the demo) I added a button to frmMain with code "Docmd.Maximize". I clicked it and nothing appeared to happen, but ever since the problem has gone away and the screen remains the correct size after running the query. And opening/closing the mdb.

But it would still be good to know what's going on in the demo, perhaps the other will play up again...
Thanks very much for looking. You guys are great helping out !
Hi. Not sure if the demo you posted is already fixed but when I closed the query, the form stayed the same when I first opened it.

I'll try to post some images to clarify later...
 
Last edited:
Hi. Not sure if the demo you posted is already fixed but when I closed the query, the form stayed the same when I first opened it.

I'll try to post some images to clarify later...
Okay, here's what it looks like when I first open the form.
attachment.php


The reason for that is because of the current Tab Order settings:
attachment.php



So, as I see it, you have two options.
1. You can adjust the tab order to put a control on the top of the form as the first one in the tab order, or
2. Move all your controls on the top of the form to the Form Header section.
 

Attachments

  • form.png
    form.png
    90.5 KB · Views: 235
  • tab.png
    tab.png
    16.3 KB · Views: 263
In reality, the form "window" isn't moving or resizing at all? This is about form controls moving up (actually, the form detail section)? Anything proposed for resizing or maximizing/restoring the form window was totally irrelevant. If I/we knew the form title bar wasn't moving that would have resulted in fewer suggestions that were of no use, I guess.
 
Cool.. thank you for looking and debugging. I would not have thought of tab order settings being to blame. I'll first try Option 1 as Form Header/Detail could be tricky (being more used to Forms in Excel). Could this also be why the Left position is sometimes offset from 0 just a little? Forms Title bar ? Micron, sorry never realised there was one to mention it. (That's the top row above the ribbon? It ain't Blue to kindof merged in).
Also, can the Nav pane be closed, as opposed to Hidden, in code? If I've read up correctly to Hide it is to remove it entirely ?
 
In retrospect I guess not (because you are using tabbed forms) but it looks like vertical scroll bar was disabled. Too bad as I think if enabled it would have made the cause/situation immediately obvious.
I've never bothered with nav as you put it. I believe it is the width property you're after. If the db is for someone else then when development is complete I hide it anyway. To "close" it programmatically is pointless IMHO as it's easy to reopen with a mouse click.
 

Users who are viewing this thread

Back
Top Bottom