1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| Public Function mfForm_AddControls()
Dim oFrm As Form, _
oText As Control, _
oLabel As Control, _
sFormName As String, _
oRset As Recordset, _
oField As Field, _
lLeft As Long, _
lTop As Long, _
lWidth As Long, _
lHight As Long, _
i As Integer
lLeft = 343
lTop = 341
lWidth = 2460
lHight = 330
sFormName = "frmMoe_VRD_AnMois_CoutChtier"
DoCmd.OpenForm sFormName, acDesign
Set oFrm = Forms(sFormName)
Set oRset = CurrentDb.OpenRecordset("qryHeure_VRD_AnMois_CoutChtier")
i = 0
For Each oField In oRset.Fields
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Creation de l'objet texte avant celui de l'objet lablel car sera le parent du label
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Set oText = CreateControl(oFrm.Name, acTextBox, acDetail, , oField.Name, lLeft, lTop + ((lHight + 150) * i), lWidth, lHight)
oText.Name = "txt" & oField.Name
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Creation de l'objet lablel dont le parent sera le'objet Texte
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Set oLabel = CreateControl(oFrm.Name, acLabel, acDetail, oText.Name, oField.Name, lLeft + lWidth + 150, lTop + ((lHight + 150) * i), lWidth, lHight)
oLabel.Name = "lbl" & oField.Name
i = i + 1
oRset.MoveNext
Next
DoCmd.OpenForm oFrm.Name, acFormPivotTable
End Function |