Solved

Center Form

Posted on 2011-02-27
5
212 Views
Last Modified: 2012-05-11
I am opening a form in one database from a button in a completely different databse.
When i open the database forms from within their original databases they are always centered but when i open them from another database they are never centered.
Anyone experienced this before?  All help welcome.
Attached is a code snipet.

Private Sub Action_Log_Click()
On Error GoTo Err_Exit_Click
    DoCmd.Close acForm, "frm_Frontpage1"
    Dim app As Access.Application
    Set app = New Access.Application
    app.OpenCurrentDatabase ("F:\Quality Systems\Action Log\Action Log v1.mdb")
    Dim SC As Long
    SC = DMax("qry_SecurityCheck.[SecurityLevel]", "qry_SecurityCheck")
    If SC = 1 Then
    app.DoCmd.OpenForm "frm_Frontpage1"
    ElseIf SC = 2 Or 23 Or 24 Then
    app.DoCmd.OpenForm "frm_Frontpage1"
    ElseIf SC = 3 Or 34 Then
    app.DoCmd.OpenForm "frm_Frontpage1"
    ElseIf SC = 4 Then
    app.DoCmd.OpenForm "frm_Frontpage1"
    End If
    app.Visible = True
    Application.Quit
Exit_Exit_Click:
    Exit Sub

Err_Exit_Click:
    MsgBox Err.Description
    Resume Exit_Exit_Click
End Sub

0
Comment
Question by:SweetingA
  • 2
  • 2
5 Comments
 

Author Comment

by:SweetingA
ID: 34992768
Oh by the way i do not want to maximise!
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 34995902
Try DoCmd.Maximize within the form's OnOpen event.

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34995915
Also you can re write your code to shorten it down.

Private Sub Action_Log_Click()
    On Error GoTo Err_Exit_Click
    
    DoCmd.Close acForm, "frm_Frontpage1"
    
    Dim app As Access.Application
    Dim SC As Long
    
    Set app = New Access.Application
    
    app.OpenCurrentDatabase ("F:\Quality Systems\Action Log\Action Log v1.mdb")
    
    SC = DMax("qry_SecurityCheck.[SecurityLevel]", "qry_SecurityCheck")
    
    Select Case SC
    Case 1 To 4, 23, 24, 34
        app.DoCmd.OpenForm "frm_Frontpage1"
    End Select
    
    app.Visible = True
    Application.Quit

Exit_Exit_Click:
    Exit Sub

Err_Exit_Click:
    MsgBox Err.Description
    Resume Exit_Exit_Click
End Sub

Open in new window


Sid
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34999104
I mean you could write code to first open the form in design view and set the "AutoCenter" property, but this would be overkill IMHO.

Perhaps an Expert knows of  a workaround, if not, you may just have to live with this...

Jeff
0
 

Author Closing Comment

by:SweetingA
ID: 35171127
You were sort of right.

The access background has to be maximised before it is hidden, otherwise the form centres itself to where the access background was originally.  As this all happend invisibly i could not see the problem.

The access background has to be maximised in the autoexec macro.

Thanks anysway it made me think a little more.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

829 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