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
| Function PeupleFormulaire()
On Error GoTo Err_peuplefrm
Dim rst As Recordset
Dim fld As Field
Dim ctl As Control
Dim ctlETiq As Control
Dim lft As Integer
Dim tp As Integer
Dim hgt As Integer
lft = 3000
tp = 100
hgt = 300
DoCmd.OpenForm "Test", acDesign, , , , acWindowNormal
Set rst = CurrentDb.OpenRecordset(Forms.test.RecordSource, dbOpenSnapshot)
For Each fld In rst.Fields
Set ctl = CreateControl("Test", acTextBox, acDetail, , fld.Name, lft, tp, 2000, hgt)
ctl.Name = fld.Name
' etiquette
Set ctlETiq = CreateControl("Test", acLabel, acDetail, ctl.Name, , 270, tp, 2650, hgt)
ctlETiq.Caption = fld.Name
tp = tp + hgt + 100
Next
DoCmd.Save acForm, "Test"
Exit Function
Err_peuplefrm:
MsgBox Err.Description
End Function |
Partager