tft每日頭條

 > 圖文

 > access如何設置彈出窗體

access如何設置彈出窗體

圖文 更新时间:2024-09-03 22:15:15
源碼示例分享!Access打開指定彈出式窗體,并将其定位在當前控件下方。

'經修改Access網友的源碼而來

'函數名稱: OpenFormFor

'frmName:,必選參數,需要打開的窗體名稱'功能描述: 打開一個彈窗式窗體定位到當前活動窗體活動控件

'2022-08-13更新了一下代碼

Public Function OpenFormFor(frmName As String, Optional strArgs As String, Optional lngX As Long = 0, Optional lngY As Long = 0)On Error GoTo Err_OpenFormForDim lngLeft As LongDim lngTop As LongDim lngWidth As LongDim lngHeight As LongDim lngBorderWidth As LongDim CurrentCtl As ControlWith Screen.ActiveFormDim frm As Object'獲取當前活動窗體控件名稱For Each frm In CurrentProject.AllFormsSet CurrentCtl = Screen.ActiveForm.ActiveControlNext frm'計算窗體左右邊框寬度lngBorderWidth = (.WindowWidth - .InsideWidth) / 2 lngLeft = .WindowLeft CurrentCtl.Left'判斷是否有記錄選擇器If .RecordSelectors Then lngLeft = .WindowLeft .WindowWidth - .InsideWidth CurrentCtl.Left - CurrentCtl.BottomPadding / 2'====================lngHeight = (.WindowHeight - .InsideHeight - lngBorderWidth)'計算定位的Y位置lngTop = .WindowTop CurrentCtl.Top CurrentCtl.Height lngHeight / 2 lngBorderWidth - CurrentCtl.BottomPadding'判斷活動控件位置在窗體頁眉或頁腳位置Select Case CurrentCtl.SectionCase acDetaillngTop = lngTop .Section(acHeader).HeightCase acFooterlngTop = lngTop .Section(acHeader).Height .Section(acDetail).HeightEnd Select'打開指定窗體,strArgs傳遞參數DoCmd.OpenForm frmName, , , , , , strArgs'定位打開窗體到活動窗體控件,lngX,lngY微調補正位置Forms(frmName).Move lngLeft lngX, lngTop lngYEnd WithExit_OpenFormFor:Exit FunctionErr_OpenFormFor:If Err = 2462 ThenResume NextElseMsgBox Err.Description, vbCritical, "Error For Function OpenFormFor"Resume Exit_OpenFormForEnd IfEnd Function

演 示:

access如何設置彈出窗體(Access打開指定彈出式窗體)1

示例下載:

Access打開指定彈出式窗體,并将其定位在當前控件下方的示例,Access窗體定位【Access軟件網】

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关圖文资讯推荐

热门圖文资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved