Form Boyutuna Göre Metin Kutu Boyutunun Yenilenmesi
#1
merhaba  modülde dlookup  kullandığımda  resimdeki hatayı alıyorum 
yardımcı olabilirmisiniz  teşekürler.


Eklenti Dosyaları
.png   Ekran Alıntısı1.PNG (Boyut: 24,23 KB / İndirilme: 35)



  Alıntı
Bu mesajı beğenenler:
#2
Sabit değere değişken eklemeye çalışıyorsunuz o nedenle hata veriyor olabilir
Constant yerine public yada global olarak dener misiniz



  Alıntı
Bu mesajı beğenenler:
#3
malesef aynı hatayı verdi  kodun tamamını paylaşıyorum 

Option Compare Database
Option Explicit
Private Const DESIGN_HORZRES As Long =DLookup("BOYUT1", "TABLO1")
Private Const DESIGN_VERTRES As Long = 770
Private Const DESIGN_PIXELS As Long = 96
Private Const WM_HORZRES As Long = 8
Private Const WM_VERTRES As Long = 10
Private Const WM_LOGPIXELSX As Long = 88
Private Const TITLEBAR_PIXELS As Long = 18
Private Const COMMANDBAR_PIXELS As Long = 26
Private Const COMMANDBAR_LEFT As Long = 0
Private Const COMMANDBAR_TOP As Long = 1
Private OrigWindow As tWindow                   '
Private Type tRect
    left As Long
    Top As Long
    right As Long
    bottom As Long
End Type
 
Private Type tDisplay
    Height As Long
    Width As Long
    DPI As Long
End Type
 
Private Type tWindow
    Height As Long
    Width As Long
End Type
 
Private Type tControl
    Name As String
    Height As Long
    Width As Long
    Top As Long
    left As Long
End Type
Private Declare PtrSafe Function WM_apiGetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
 
Private Declare PtrSafe Function WM_apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" _
() As Long
 
Private Declare PtrSafe Function WM_apiGetDC Lib "user32" Alias "GetDC" _
(ByVal hWnd As Long) As Long
 
Private Declare PtrSafe Function WM_apiReleaseDC Lib "user32" Alias "ReleaseDC" _
(ByVal hWnd As Long, ByVal hdc As Long) As Long
 
Private Declare PtrSafe Function WM_apiGetWindowRect Lib "user32.dll" Alias "GetWindowRect" _
(ByVal hWnd As Long, lpRect As tRect) As Long
 
Private Declare PtrSafe Function WM_apiMoveWindow Lib "user32.dll" Alias "MoveWindow" _
(ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
 
Private Declare PtrSafe Function WM_apiIsZoomed Lib "user32.dll" Alias "IsZoomed" _
(ByVal hWnd As Long) As Long
Private Function getScreenResolution() As tDisplay
 
Dim hDCcaps As Long
Dim lngRtn As Long
 
On Error Resume Next

    hDCcaps = WM_apiGetDC(0)
    With getScreenResolution
        .Height = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
        .Width = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
        .DPI = WM_apiGetDeviceCaps(hDCcaps, WM_LOGPIXELSX)
    End With
    lngRtn = WM_apiReleaseDC(0, hDCcaps)
 
End Function
Private Function getFactor(blnVert As Boolean) As Single
 
Dim sngFactorP As Single
 
On Error Resume Next
 
    If getScreenResolution.DPI <> 0 Then
        sngFactorP = DESIGN_PIXELS / getScreenResolution.DPI
    Else
        sngFactorP = 1 'Error with dpi reported so assume 96 dpi.
    End If
    If blnVert Then 'return vertical resolution.
        getFactor = (getScreenResolution.Height / DESIGN_VERTRES) * sngFactorP
    Else 'return horizontal resolution.
        getFactor = (getScreenResolution.Width / DESIGN_HORZRES) * sngFactorP
    End If
 
End Function
  
Public Sub ReSizeFormMASA(ByVal frm As Access.Form)
 
Dim rectWindow As tRect
Dim lngWidth As Long
Dim lngHeight As Long
Dim sngVertFactor As Single
Dim sngHorzFactor As Single
Dim sngFontFactor As Single
 
On Error Resume Next
 
    sngVertFactor = getFactor(True)  'Local function returns vertical size change.
    sngHorzFactor = getFactor(False)  'Local function returns horizontal size change.
    'Choose lowest factor for resizing fonts:-
    sngFontFactor = VBA.IIf(sngHorzFactor < sngVertFactor, sngHorzFactor, sngVertFactor)
    Resize sngVertFactor, sngHorzFactor, sngFontFactor, frm 'Local procedure to resize form sections & controls.
    If WM_apiIsZoomed(frm.hWnd) = 0 Then 'Don't change window settings for max'd form.
        Access.DoCmd.RunCommand acCmdAppMaximize 'Maximize the Access Window.
        'Store for dimensions in rectWindow:-
        Call WM_apiGetWindowRect(frm.hWnd, rectWindow)
        'Calculate and store form height and width in local variables:-
        With rectWindow
            lngWidth = .right - .left
            lngHeight = .bottom - .Top
        End With
        'Resize the form window as required (don't resize this for sub forms):-
        If frm.Parent.Name = VBA.vbNullString Then
            Call WM_apiMoveWindow(frm.hWnd, ((getScreenResolution.Width - _
            (sngHorzFactor * lngWidth)) / 2) - getLeftOffset, _
            ((getScreenResolution.Height - (sngVertFactor * lngHeight)) / 2) - _
            getTopOffset, lngWidth * sngHorzFactor, lngHeight * sngVertFactor, 1)
        End If
    End If
    Set frm = Nothing 'Free up resources.
 
End Sub
  
Private Sub Resize(sngVertFactor As Single, sngHorzFactor As Single, sngFontFactor As _
Single, ByVal frm As Access.Form)
 
Dim ctl As Access.Control            'Form control variable.
Dim arrCtls() As tControl            'Array of Tab and Option Group control properties.
Dim lngI As Long                     'Loop counter.
Dim lngJ As Long                     'Loop counter.
Dim lngWidth As Long                 'Stores form's new width.
Dim lngHeaderHeight As Long          'Stores header's new height.
Dim lngDetailHeight As Long          'Stores detail's new height.
Dim lngFooterHeight As Long          'Stores footer's new height.
Dim blnHeaderVisible As Boolean      'True if form header visible before resize.
Dim blnDetailVisible As Boolean      'True if form detail visible before resize.
Dim blnFooterVisible As Boolean      'True if form footer visible before resize.
Const FORM_MAX As Long = 31680       'Maximum possible form width & section height.
 
On Error Resume Next
 
    With frm
        .Painting = False 'Turn off form painting.
        'Calculate form's new with and section heights and store in local variables
        'for later use:-
        lngWidth = .Width * sngHorzFactor
        lngHeaderHeight = .Section(Access.acHeader).Height * sngVertFactor
        lngDetailHeight = .Section(Access.acDetail).Height * sngVertFactor
        lngFooterHeight = .Section(Access.acFooter).Height * sngVertFactor
        'Now maximize the form's width and height while controls are being resized:-
        .Width = FORM_MAX
        .Section(Access.acHeader).Height = FORM_MAX
        .Section(Access.acDetail).Height = FORM_MAX
        .Section(Access.acFooter).Height = FORM_MAX
        'Hiding form sections during resize prevents invalid page fault after
        'resizing column widths for list boxes on forms with a header/footer:-
        blnHeaderVisible = .Section(Access.acHeader).Visible
        blnDetailVisible = .Section(Access.acDetail).Visible
        blnFooterVisible = .Section(Access.acFooter).Visible
        .Section(Access.acHeader).Visible = False
        .Section(Access.acDetail).Visible = False
        .Section(Access.acFooter).Visible = False
    End With
    'Resize array to hold 1 element:-
    ReDim arrCtls(0)
    'Gather properties for Tabs and Option Groups to recify height/width problems:-
    For Each ctl In frm.Controls
        If ((ctl.ControlType = Access.acTabCtl) Or _
        (ctl.ControlType = Access.acOptionGroup)) Then
            With arrCtls(lngI)
                .Name = ctl.Name
                .Height = ctl.Height
                .Width = ctl.Width
                .Top = ctl.Top
                .left = ctl.left
            End With
            lngI = lngI + 1
            ReDim Preserve arrCtls(lngI) 'Increase the size of the array.
        End If
    Next ctl
    'Resize and locate each control:-
    For Each ctl In frm.Controls
        If ctl.ControlType <> Access.acPage Then 'Ignore pages in Tab controls.
            With ctl
                .Height = .Height * sngVertFactor
                .left = .left * sngHorzFactor
                .Top = .Top * sngVertFactor
                .Width = .Width * sngHorzFactor
                .fontsize = .fontsize * sngFontFactor
                'Enhancement by Myke Myers --------------------------------------->
                'Fix certain Combo Box, List Box and Tab control properties:-
                Select Case .ControlType
                    Case Access.acListBox
                        .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
                    Case Access.acComboBox
                        .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
                        .ListWidth = .ListWidth * sngHorzFactor
                    Case Access.acTabCtl
                        .TabFixedWidth = .TabFixedWidth * sngHorzFactor
                        .TabFixedHeight = .TabFixedHeight * sngVertFactor
                End Select
                '------------------------------------> End enhancement by Myke Myers.
            End With
        End If
    Next ctl

    For lngJ = 0 To lngI
        With frm.Controls.Item(arrCtls(lngJ).Name)
            .left = arrCtls(lngJ).left * sngHorzFactor
            .Top = arrCtls(lngJ).Top * sngVertFactor
            .Height = arrCtls(lngJ).Height * sngVertFactor
            .Width = arrCtls(lngJ).Width * sngHorzFactor
        End With
    Next lngJ
    'Now resize height for each section and form width using stored values:-
    With frm
        .Width = lngWidth
        .Section(Access.acHeader).Height = lngHeaderHeight
        .Section(Access.acDetail).Height = lngDetailHeight
        .Section(Access.acFooter).Height = lngFooterHeight
        'Now unhide form sections:-
        .Section(Access.acHeader).Visible = blnHeaderVisible
        .Section(Access.acDetail).Visible = blnDetailVisible
        .Section(Access.acFooter).Visible = blnFooterVisible
        .Painting = True 'Turn form painting on.
    End With
    Erase arrCtls 'Destory array.
    Set ctl = Nothing 'Free up resources.
 
End Sub
 

Private Function getTopOffset() As Long
 
Dim cmdBar As Object
Dim lngI As Long
 
On Error GoTo err
 
     For Each cmdBar In Application.CommandBars
        If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_TOP)) Then
            lngI = lngI + 1
        End If
     Next cmdBar
     getTopOffset = (TITLEBAR_PIXELS + (lngI * COMMANDBAR_PIXELS))
 
exit_fun:
    Exit Function
 
err:
    'Assume only 1 visible command bar plus the title bar:
    getTopOffset = TITLEBAR_PIXELS + COMMANDBAR_PIXELS
    Resume exit_fun
 
End Function
 
Private Function getLeftOffset() As Long
 
Dim cmdBar As Object
Dim lngI As Long
 
On Error GoTo err
 
     For Each cmdBar In Application.CommandBars
        If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_LEFT)) Then
            lngI = lngI + 1
        End If
     Next cmdBar
     getLeftOffset = (lngI * COMMANDBAR_PIXELS)
 
exit_fun:
    Exit Function
 
err:
    'Assume no visible command bars:-
    getLeftOffset = 0
    Resume exit_fun
 
End Function

Private Function adjustColumnWidths(strColumnWidths As String, sngFactor As Single) As String
On Error GoTo Err_adjustColumnWidths
 
Dim astrColumnWidths() As String                'Array to hold the individual column widths
Dim strTemp As String                           'Holds the recombined columnwidths string
Dim lngI As Long                                'For Loop counter
Dim lngJ As Long                                'Columnwidths counter
 
    'Get the column widths:-
    'THIS CODE BY JAMIE CZERNIK------------------------------------------->
    'Replace the Split() function as not available in Access 97:
    'Sets the array to one entry.
    ReDim astrColumnWidths(0)
    'Loops through each character in the Column Widths String passed in by the calling code.
    For lngI = 1 To VBA.Len(strColumnWidths)
        'Looks for each semicolon, which is what separates the individual Column Widths.
        Select Case VBA.Mid(strColumnWidths, lngI, 1)
            'If a semicolon is not found, the character is added to the any characters
            ' already in the columnwidths entry in the array.  If it is found, the
            ' Columnwidths Counter is incremented by one and the array is increased by
            ' one while retaining entered data so that the next columnwidth can be entered.
            Case Is <> ";"
                astrColumnWidths(lngJ) = astrColumnWidths(lngJ) & VBA.Mid( _
                strColumnWidths, lngI, 1)
            Case ";"
                lngJ = lngJ + 1
                ReDim Preserve astrColumnWidths(lngJ) 'Resize the array.
        End Select
    Next lngI
    'Resets the loop counter to 0.
    lngI = 0
    '--------------------------------------------> END CODE BY JAMIE CZERNIK.
    'Access 2000/2002 users can uncomment the line below and remove the split() code
    'replacement above.
    'astrColumnWidths = Split(strColumnWidths, ";")'Available in Access 2000/2002 only
    strTemp = VBA.vbNullString 'Sets the temp variable to a null string
    'Loops through the all the columnwidths in the array, converting them to the new sizes
    ' (using the Width Size Conversion Factor that was passed-in), and recombining them
    ' into a single string to pass back to the calling code. (If there is no Column Width,
    ' the value is left blank.)
    Do Until lngI > UBound(astrColumnWidths)
        If Not IsNull(astrColumnWidths(lngI)) And astrColumnWidths(lngI) <> "" Then
            strTemp = strTemp & CSng(astrColumnWidths(lngI)) * sngFactor & ";"
        End If
        lngI = lngI + 1
    Loop
    'Returns the combined columnwidths string to the calling code.
    adjustColumnWidths = strTemp
    Erase astrColumnWidths 'Destroy array.
 
Exit_adjustColumnWidths:
    On Error Resume Next
    Exit Function
 
Err_adjustColumnWidths:
    Erase astrColumnWidths 'Destroy array.
    Resume Exit_adjustColumnWidths
 
End Function

Public Sub getOrigWindow(frm As Access.Form)
 
On Error Resume Next
 
    OrigWindow.Height = frm.WindowHeight
    OrigWindow.Width = frm.WindowWidth
 
End Sub

Public Sub RestoreWindow()
 
On Error Resume Next
 
    Access.DoCmd.MoveSize , , OrigWindow.Width, OrigWindow.Height
    Access.DoCmd.Save
 
End Sub



  Alıntı
Bu mesajı beğenenler:
#4
Çalışmanızı ekleyin inceleyelim
Private Const DESIGN_HORZRES As Long =DLookup("BOYUT1", "TABLO1") bunun yerine
Private DESIGN_HORZRES As Long olarak tanımlayın
Form açılışında formopen yada formload olayına da
DESIGN_HORZRES=DLookup("BOYUT1", "TABLO1") kodunu ekleyerek dener misiniz



  Alıntı
Bu mesajı beğenenler:
#5
denedim çalışmadı ornek ekledeim bakabilirmisiniz


Eklenti Dosyaları
.rar   ORNEK.rar (Boyut: 30,98 KB / İndirilme: 28)



  Alıntı
Bu mesajı beğenenler:
#6
Private Const DESIGN_HORZRES As Long =DLookup("BOYUT1", "TABLO1") 2 tane buna benzer tanımlamanız vardı Const yani sabit olmalarına rağmen siz bunlara değişken atamaya çalıştığınız için hata veriyordu galiba o nedenle sabitlik ifadesini kaldırıp değer atamasını kullanıldıkları kullanıldıkları getFactor fonksiyonunun içine aldım

modül kodlarını aşağıdaki gibi düzenleyip dener misiniz?
Visual Basic
  1. Option Compare Database
  2. Option Explicit
  3. Private DESIGN_HORZRES As Long '= DLookup("EN", "Tablo1")
  4. Private DESIGN_VERTRES As Long '= DLookup("BOY", "Tablo1")
  5. Private Const DESIGN_PIXELS As Long = 96
  6. Private Const WM_HORZRES As Long = 8
  7. Private Const WM_VERTRES As Long = 10
  8. Private Const WM_LOGPIXELSX As Long = 88
  9. Private Const TITLEBAR_PIXELS As Long = 18
  10. Private Const COMMANDBAR_PIXELS As Long = 26
  11. Private Const COMMANDBAR_LEFT As Long = 0
  12. Private Const COMMANDBAR_TOP As Long = 1
  13. Private OrigWindow As tWindow '
  14. Private Type tRect
  15. left As Long
  16. Top As Long
  17. right As Long
  18. bottom As Long
  19. End Type
  20.  
  21. Private Type tDisplay
  22. Height As Long
  23. Width As Long
  24. DPI As Long
  25. End Type
  26.  
  27. Private Type tWindow
  28. Height As Long
  29. Width As Long
  30. End Type
  31.  
  32. Private Type tControl
  33. Name As String
  34. Height As Long
  35. Width As Long
  36. Top As Long
  37. left As Long
  38. End Type
  39. Private Declare PtrSafe Function WM_apiGetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" _
  40. (ByVal hdc As Long, ByVal nIndex As Long) As Long
  41.  
  42. Private Declare PtrSafe Function WM_apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" _
  43. () As Long
  44.  
  45. Private Declare PtrSafe Function WM_apiGetDC Lib "user32" Alias "GetDC" _
  46. (ByVal hWnd As Long) As Long
  47.  
  48. Private Declare PtrSafe Function WM_apiReleaseDC Lib "user32" Alias "ReleaseDC" _
  49. (ByVal hWnd As Long, ByVal hdc As Long) As Long
  50.  
  51. Private Declare PtrSafe Function WM_apiGetWindowRect Lib "user32.dll" Alias "GetWindowRect" _
  52. (ByVal hWnd As Long, lpRect As tRect) As Long
  53.  
  54. Private Declare PtrSafe Function WM_apiMoveWindow Lib "user32.dll" Alias "MoveWindow" _
  55. (ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
  56. ByVal nHeight As Long, ByVal bRepaint As Long) As Long
  57.  
  58. Private Declare PtrSafe Function WM_apiIsZoomed Lib "user32.dll" Alias "IsZoomed" _
  59. (ByVal hWnd As Long) As Long
  60. Private Function getScreenResolution() As tDisplay
  61.  
  62. Dim hDCcaps As Long
  63. Dim lngRtn As Long
  64.  
  65. On Error Resume Next
  66.  
  67. hDCcaps = WM_apiGetDC(0)
  68. With getScreenResolution
  69. .Height = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
  70. .Width = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
  71. .DPI = WM_apiGetDeviceCaps(hDCcaps, WM_LOGPIXELSX)
  72. End With
  73. lngRtn = WM_apiReleaseDC(0, hDCcaps)
  74.  
  75. End Function
  76. Private Function getFactor(blnVert As Boolean) As Single
  77. DESIGN_HORZRES = DLookup("EN", "Tablo1")
  78. DESIGN_VERTRES = DLookup("BOY", "Tablo1")
  79. Dim sngFactorP As Single
  80.  
  81. On Error Resume Next
  82.  
  83. If getScreenResolution.DPI <> 0 Then
  84. sngFactorP = DESIGN_PIXELS / getScreenResolution.DPI
  85. Else
  86. sngFactorP = 1 'Error with dpi reported so assume 96 dpi.
  87. End If
  88. If blnVert Then 'return vertical resolution.
  89. getFactor = (getScreenResolution.Height / DESIGN_VERTRES) * sngFactorP
  90. Else 'return horizontal resolution.
  91. getFactor = (getScreenResolution.Width / DESIGN_HORZRES) * sngFactorP
  92. End If
  93.  
  94. End Function
  95.  
  96. Public Sub ReSizeFormMASA(ByVal frm As Access.Form)
  97.  
  98. Dim rectWindow As tRect
  99. Dim lngWidth As Long
  100. Dim lngHeight As Long
  101. Dim sngVertFactor As Single
  102. Dim sngHorzFactor As Single
  103. Dim sngFontFactor As Single
  104.  
  105. On Error Resume Next
  106.  
  107. sngVertFactor = getFactor(True) 'Local function returns vertical size change.
  108. sngHorzFactor = getFactor(False) 'Local function returns horizontal size change.
  109. 'Choose lowest factor for resizing fonts:-
  110. sngFontFactor = VBA.IIf(sngHorzFactor < sngVertFactor, sngHorzFactor, sngVertFactor)
  111. Resize sngVertFactor, sngHorzFactor, sngFontFactor, frm 'Local procedure to resize form sections & controls.
  112. If WM_apiIsZoomed(frm.hWnd) = 0 Then 'Don't change window settings for max'd form.
  113. Access.DoCmd.RunCommand acCmdAppMaximize 'Maximize the Access Window.
  114. 'Store for dimensions in rectWindow:-
  115. Call WM_apiGetWindowRect(frm.hWnd, rectWindow)
  116. 'Calculate and store form height and width in local variables:-
  117. With rectWindow
  118. lngWidth = .right - .left
  119. lngHeight = .bottom - .Top
  120. End With
  121. 'Resize the form window as required (don't resize this for sub forms):-
  122. If frm.Parent.Name = VBA.vbNullString Then
  123. Call WM_apiMoveWindow(frm.hWnd, ((getScreenResolution.Width - _
  124. (sngHorzFactor * lngWidth)) / 2) - getLeftOffset, _
  125. ((getScreenResolution.Height - (sngVertFactor * lngHeight)) / 2) - _
  126. getTopOffset, lngWidth * sngHorzFactor, lngHeight * sngVertFactor, 1)
  127. End If
  128. End If
  129. Set frm = Nothing 'Free up resources.
  130.  
  131. End Sub
  132.  
  133. Private Sub Resize(sngVertFactor As Single, sngHorzFactor As Single, sngFontFactor As _
  134. Single, ByVal frm As Access.Form)
  135.  
  136. Dim ctl As Access.Control 'Form control variable.
  137. Dim arrCtls() As tControl 'Array of Tab and Option Group control properties.
  138. Dim lngI As Long 'Loop counter.
  139. Dim lngJ As Long 'Loop counter.
  140. Dim lngWidth As Long 'Stores form's new width.
  141. Dim lngHeaderHeight As Long 'Stores header's new height.
  142. Dim lngDetailHeight As Long 'Stores detail's new height.
  143. Dim lngFooterHeight As Long 'Stores footer's new height.
  144. Dim blnHeaderVisible As Boolean 'True if form header visible before resize.
  145. Dim blnDetailVisible As Boolean 'True if form detail visible before resize.
  146. Dim blnFooterVisible As Boolean 'True if form footer visible before resize.
  147. Const FORM_MAX As Long = 31680 'Maximum possible form width & section height.
  148.  
  149. On Error Resume Next
  150.  
  151. With frm
  152. .Painting = False 'Turn off form painting.
  153. 'Calculate form's new with and section heights and store in local variables
  154. 'for later use:-
  155. lngWidth = .Width * sngHorzFactor
  156. lngHeaderHeight = .Section(Access.acHeader).Height * sngVertFactor
  157. lngDetailHeight = .Section(Access.acDetail).Height * sngVertFactor
  158. lngFooterHeight = .Section(Access.acFooter).Height * sngVertFactor
  159. 'Now maximize the form's width and height while controls are being resized:-
  160. .Width = FORM_MAX
  161. .Section(Access.acHeader).Height = FORM_MAX
  162. .Section(Access.acDetail).Height = FORM_MAX
  163. .Section(Access.acFooter).Height = FORM_MAX
  164. 'Hiding form sections during resize prevents invalid page fault after
  165. 'resizing column widths for list boxes on forms with a header/footer:-
  166. blnHeaderVisible = .Section(Access.acHeader).Visible
  167. blnDetailVisible = .Section(Access.acDetail).Visible
  168. blnFooterVisible = .Section(Access.acFooter).Visible
  169. .Section(Access.acHeader).Visible = False
  170. .Section(Access.acDetail).Visible = False
  171. .Section(Access.acFooter).Visible = False
  172. End With
  173. 'Resize array to hold 1 element:-
  174. ReDim arrCtls(0)
  175. 'Gather properties for Tabs and Option Groups to recify height/width problems:-
  176. For Each ctl In frm.Controls
  177. If ((ctl.ControlType = Access.acTabCtl) Or _
  178. (ctl.ControlType = Access.acOptionGroup)) Then
  179. With arrCtls(lngI)
  180. .Name = ctl.Name
  181. .Height = ctl.Height
  182. .Width = ctl.Width
  183. .Top = ctl.Top
  184. .left = ctl.left
  185. End With
  186. lngI = lngI + 1
  187. ReDim Preserve arrCtls(lngI) 'Increase the size of the array.
  188. End If
  189. Next ctl
  190. 'Resize and locate each control:-
  191. For Each ctl In frm.Controls
  192. If ctl.ControlType <> Access.acPage Then 'Ignore pages in Tab controls.
  193. With ctl
  194. .Height = .Height * sngVertFactor
  195. .left = .left * sngHorzFactor
  196. .Top = .Top * sngVertFactor
  197. .Width = .Width * sngHorzFactor
  198. .FontSize = .FontSize * sngFontFactor
  199. 'Enhancement by Myke Myers --------------------------------------->
  200. 'Fix certain Combo Box, List Box and Tab control properties:-
  201. Select Case .ControlType
  202. Case Access.acListBox
  203. .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
  204. Case Access.acComboBox
  205. .ColumnWidths = adjustColumnWidths(.ColumnWidths, sngHorzFactor)
  206. .ListWidth = .ListWidth * sngHorzFactor
  207. Case Access.acTabCtl
  208. .TabFixedWidth = .TabFixedWidth * sngHorzFactor
  209. .TabFixedHeight = .TabFixedHeight * sngVertFactor
  210. End Select
  211. '------------------------------------> End enhancement by Myke Myers.
  212. End With
  213. End If
  214. Next ctl
  215.  
  216. For lngJ = 0 To lngI
  217. With frm.Controls.Item(arrCtls(lngJ).Name)
  218. .left = arrCtls(lngJ).left * sngHorzFactor
  219. .Top = arrCtls(lngJ).Top * sngVertFactor
  220. .Height = arrCtls(lngJ).Height * sngVertFactor
  221. .Width = arrCtls(lngJ).Width * sngHorzFactor
  222. End With
  223. Next lngJ
  224. 'Now resize height for each section and form width using stored values:-
  225. With frm
  226. .Width = lngWidth
  227. .Section(Access.acHeader).Height = lngHeaderHeight
  228. .Section(Access.acDetail).Height = lngDetailHeight
  229. .Section(Access.acFooter).Height = lngFooterHeight
  230. 'Now unhide form sections:-
  231. .Section(Access.acHeader).Visible = blnHeaderVisible
  232. .Section(Access.acDetail).Visible = blnDetailVisible
  233. .Section(Access.acFooter).Visible = blnFooterVisible
  234. .Painting = True 'Turn form painting on.
  235. End With
  236. Erase arrCtls 'Destory array.
  237. Set ctl = Nothing 'Free up resources.
  238.  
  239. End Sub
  240.  
  241.  
  242. Private Function getTopOffset() As Long
  243.  
  244. Dim cmdBar As Object
  245. Dim lngI As Long
  246.  
  247. On Error GoTo err
  248.  
  249. For Each cmdBar In Application.CommandBars
  250. If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_TOP)) Then
  251. lngI = lngI + 1
  252. End If
  253. Next cmdBar
  254. getTopOffset = (TITLEBAR_PIXELS + (lngI * COMMANDBAR_PIXELS))
  255.  
  256. exit_fun:
  257. Exit Function
  258.  
  259. err:
  260. 'Assume only 1 visible command bar plus the title bar:
  261. getTopOffset = TITLEBAR_PIXELS + COMMANDBAR_PIXELS
  262. Resume exit_fun
  263.  
  264. End Function
  265.  
  266. Private Function getLeftOffset() As Long
  267.  
  268. Dim cmdBar As Object
  269. Dim lngI As Long
  270.  
  271. On Error GoTo err
  272.  
  273. For Each cmdBar In Application.CommandBars
  274. If ((cmdBar.Visible = True) And (cmdBar.Position = COMMANDBAR_LEFT)) Then
  275. lngI = lngI + 1
  276. End If
  277. Next cmdBar
  278. getLeftOffset = (lngI * COMMANDBAR_PIXELS)
  279.  
  280. exit_fun:
  281. Exit Function
  282.  
  283. err:
  284. 'Assume no visible command bars:-
  285. getLeftOffset = 0
  286. Resume exit_fun
  287.  
  288. End Function
  289.  
  290. Private Function adjustColumnWidths(strColumnWidths As String, sngFactor As Single) As String
  291. On Error GoTo Err_adjustColumnWidths
  292.  
  293. Dim astrColumnWidths() As String 'Array to hold the individual column widths
  294. Dim strTemp As String 'Holds the recombined columnwidths string
  295. Dim lngI As Long 'For Loop counter
  296. Dim lngJ As Long 'Columnwidths counter
  297.  
  298. 'Get the column widths:-
  299. 'THIS CODE BY JAMIE CZERNIK------------------------------------------->
  300. 'Replace the Split() function as not available in Access 97:
  301. 'Sets the array to one entry.
  302. ReDim astrColumnWidths(0)
  303. 'Loops through each character in the Column Widths String passed in by the calling code.
  304. For lngI = 1 To VBA.Len(strColumnWidths)
  305. 'Looks for each semicolon, which is what separates the individual Column Widths.
  306. Select Case VBA.Mid(strColumnWidths, lngI, 1)
  307. 'If a semicolon is not found, the character is added to the any characters
  308. ' already in the columnwidths entry in the array. If it is found, the
  309. ' Columnwidths Counter is incremented by one and the array is increased by
  310. ' one while retaining entered data so that the next columnwidth can be entered.
  311. Case Is <> ";"
  312. astrColumnWidths(lngJ) = astrColumnWidths(lngJ) & VBA.Mid( _
  313. strColumnWidths, lngI, 1)
  314. Case ";"
  315. lngJ = lngJ + 1
  316. ReDim Preserve astrColumnWidths(lngJ) 'Resize the array.
  317. End Select
  318. Next lngI
  319. 'Resets the loop counter to 0.
  320. lngI = 0
  321. '--------------------------------------------> END CODE BY JAMIE CZERNIK.
  322. 'Access 2000/2002 users can uncomment the line below and remove the split() code
  323. 'replacement above.
  324. 'astrColumnWidths = Split(strColumnWidths, ";")'Available in Access 2000/2002 only
  325. strTemp = VBA.vbNullString 'Sets the temp variable to a null string
  326. 'Loops through the all the columnwidths in the array, converting them to the new sizes
  327. ' (using the Width Size Conversion Factor that was passed-in), and recombining them
  328. ' into a single string to pass back to the calling code. (If there is no Column Width,
  329. ' the value is left blank.)
  330. Do Until lngI > UBound(astrColumnWidths)
  331. If Not IsNull(astrColumnWidths(lngI)) And astrColumnWidths(lngI) <> "" Then
  332. strTemp = strTemp & CSng(astrColumnWidths(lngI)) * sngFactor & ";"
  333. End If
  334. lngI = lngI + 1
  335. Loop
  336. 'Returns the combined columnwidths string to the calling code.
  337. adjustColumnWidths = strTemp
  338. Erase astrColumnWidths 'Destroy array.
  339.  
  340. Exit_adjustColumnWidths:
  341. On Error Resume Next
  342. Exit Function
  343.  
  344. Err_adjustColumnWidths:
  345. Erase astrColumnWidths 'Destroy array.
  346. Resume Exit_adjustColumnWidths
  347.  
  348. End Function
  349.  
  350. Public Sub getOrigWindow(frm As Access.Form)
  351.  
  352. On Error Resume Next
  353.  
  354. OrigWindow.Height = frm.WindowHeight
  355. OrigWindow.Width = frm.WindowWidth
  356.  
  357. End Sub
  358.  
  359. Public Sub RestoreWindow()
  360.  
  361. On Error Resume Next
  362.  
  363. Access.DoCmd.MoveSize , , OrigWindow.Width, OrigWindow.Height
  364. Access.DoCmd.Save
  365.  
  366. End Sub





  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  [FORM] Formda Kriterlere Göre Sorgulanan Kayıt Miktarının Form üzerinde Gösterilmesi M_Kemal_Askeri 1 64 13-05-2024, 05:10
Son Mesaj: dsezgin
  Açılır Kutu Değerine Göre Tablo2'ye Değer Yazsın Veya Satır Eklesin. ŞabanTR 11 305 24-12-2023, 14:38
Son Mesaj: dsezgin
  [FORM] Metin Kutusundaki Değere Göre Altforma Kayıt Eklensin Yada Eklenmesin ŞabanTR 4 172 17-12-2023, 17:40
Son Mesaj: ŞabanTR
  Uzun Metin Formatını Sql De Kısa Metin Formatına çevirebilir Miyiz? adnnfrm 2 210 06-08-2023, 03:51
Son Mesaj: adnnfrm
  Metin Kutusu Boş Sa Diğer Metin Kutusundan Değer Alması özgülapt 4 269 29-05-2023, 18:01
Son Mesaj: feraz
  Ana Menüden 2.form Açtığımda Form Görev çubuğuna Inmiyor. 32'den 64'e Geçiş Hatası OGUZTURKYILMAZ 3 257 13-04-2023, 23:39
Son Mesaj: OGUZTURKYILMAZ
access-sql-18 [FORM] Birleşik Kutu Ile Form Kayıt Kaynağı Değiştirmek. BeyTor 2 210 27-03-2023, 03:43
Son Mesaj: BeyTor
  Alt Form Metin Kutularına Veri Girişi krem 14 400 05-01-2023, 00:51
Son Mesaj: krem

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi