A way to accurately size a pop-up form

lundi 4 mai 2015

Some time ago when I was programming in Access 2000, I used to get frustrated because I could never by sure what size a pop-up form would be and where it would appear. As a result, I used the code shown below to precisely size and position my form, then set PopUp = True; Modal = True. It did the trick and I could set the size and position using inches instead of Twips. It worked fine back then. I have needed to return to this technique, but I think Access has changed or I have forgotten the other settings because this no longer works for me. I think that maybe I have forgotten some other form settings.

Note: I realize there probably is an easier way to size and position, but this template had worked so well in the past. I am just trying to see if there is a simple explanation on why it is not working now.

Question: looking at my code (below), can anyone think of why it is not allowing me to size and position my form?


------------------------------------------------------------
In a regular module, I have the following statement:

Code:

Global Const gcint_Inches_to_Twips As Integer = 1440
At the top of the form module in the declaration area, I have the following code and I set the size and position of the form in inches:

Code:

Private Const mcsng_Form_Right_in_Inches As Single = 2.3
Private Const mcsng_Form_Down_in_Inches As Single = 1.5
Private Const mcsng_Form_Width_in_Inches As Single = 4.5
Private Const mcsng_Form_Height_in_Inches As Single = 2.5

In the Form Load event, I have the following:

Code:

Private Sub Form_Load()
    With DoCmd
        .MoveSize Right:=(mcsng_Form_Right_in_Inches * gcint_Inches_to_Twips)
        .MoveSize Down:=(mcsng_Form_Down_in_Inches * gcint_Inches_to_Twips)
        .MoveSize Width:=(mcsng_Form_Width_in_Inches * gcint_Inches_to_Twips)
        .MoveSize Height:=(mcsng_Form_Height_in_Inches * gcint_Inches_to_Twips)
        .Restore
    End With

End Sub

A way to accurately size a pop-up form

0 commentaires:

Enregistrer un commentaire

Labels