Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

v2002 CreateControl

2 réponses
Avatar
Blaise Cacramp
Bonjour

Si, en VBA, j'arrive à utiliser CreateControl, je n'arrive pas à maîtriser
le nom du contrôle ou toute autre information l'identifiant pour mettre à
jour ses propriétés comme le nom, le masque, etc

Ci-dessous, le code utilisé actuellement, copie légèrement améliorée de
l'aide MS.

Meilleures salutations,

Blaise
-----------------------------------------------------------
Dim ctlLabel As Control, ctlText As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer

On Error Resume Next
DoCmd.DeleteObject acForm, "Frm_Ouvrage"
On Error GoTo 0

DoCmd.CopyObject , "Frm_Ouvrage", acForm, "Frm_Coucou"


DoCmd.OpenForm "Frm_Ouvrage", acDesign

' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl("Frm_Ouvrage", acTextBox, , "", "", _
intDataX, intDataY)




' Create child label control for text box.
Set ctlLabel = CreateControl("Frm_Ouvrage", acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
DoCmd.Save acForm, "Frm_Ouvrage"
DoCmd.OpenForm "Frm_Ouvrage", acNormal

2 réponses

Avatar
Gloops
[Comment nommer un nouveau contrôle pendant sa création ?]

Bonsoir,

Je suis à moitié réveillé, mais je me lance quand même ...

Blaise Cacramp a écrit, le 30/01/2008 21:41 :

DoCmd.OpenForm "Frm_Ouvrage", acDesign

' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl("Frm_Ouvrage", acTextBox, , "", "", _
intDataX, intDataY)



Que se passe-t-il si tu mets ici ctlText.Name = "txtNomMagique" ?




' Create child label control for text box.
Set ctlLabel = CreateControl("Frm_Ouvrage", acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
DoCmd.Save acForm, "Frm_Ouvrage"
DoCmd.OpenForm "Frm_Ouvrage", acNormal





Avatar
Blaise Cacramp
Pour une fois, c'est simple !

merci beaucoup
"Gloops" a écrit dans le message de
news:OB$
[Comment nommer un nouveau contrôle pendant sa création ?]

Bonsoir,

Je suis à moitié réveillé, mais je me lance quand même ...

Blaise Cacramp a écrit, le 30/01/2008 21:41 :

DoCmd.OpenForm "Frm_Ouvrage", acDesign

' Set positioning values for new controls.
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
' Create unbound default-size text box in detail section.
Set ctlText = CreateControl("Frm_Ouvrage", acTextBox, , "", "", _
intDataX, intDataY)



Que se passe-t-il si tu mets ici ctlText.Name = "txtNomMagique" ?




' Create child label control for text box.
Set ctlLabel = CreateControl("Frm_Ouvrage", acLabel, , _
ctlText.Name, "NewLabel", intLabelX, intLabelY)
' Restore form.
DoCmd.Restore
DoCmd.Save acForm, "Frm_Ouvrage"
DoCmd.OpenForm "Frm_Ouvrage", acNormal