Solved

Center Form

Posted on 2011-02-27
5
209 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now