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

mdl.InsertText (97)

3 réponses
Avatar
Hugo Degueldre
Bonjour,

Un doué de la quote pourrait-il m'aider à habiller les 2 lignes de code
reprise dans le bout de code ci-dessous.

Comme à chaque fois, je rame (après de nombreux essais) à placer les ", '",
"""; "'", Chr(34) aux endroits corrects.

D'avance merci.

Set comZoom = CreateControl(Form.Name, acCommandButton, , , , 13100, 1000,
1300, 1000)
With comZoom
.Name = "comZoom"
.Caption = "ZOOM"
.OnClick = "[Procédure événementielle]"
Dim mdlZoom As Module
Set mdlZoom = Forms!Formulaire2.Module
Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom" & "_Click()" & vbCrLf _
& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt" &
Chr(34) & " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _
------------------------------------------------------------
-------------------------------------------------------------------
CE SONT LES 2 LIGNES QUI SUIVENT QUI ME CAUSENT PROBLEME
------------------------------------------------------------
------------------------------------------------------------------
& vbTab & "leTit = DLookup("[titulaire, "tbEmploi",
"[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _
& vbTab & "lHisto = DLookup("[DernierDetitulaireHisto]",
"tbEmploi", "[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _

& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub" _
mdl.InsertText chTexteZoom
End With

3 réponses

Avatar
Jessy Sempere [MVP]
Bonjour

Essais :



--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Hugo Degueldre" a écrit dans le message
news: 409217ca$0$25085$
Bonjour,

Un doué de la quote pourrait-il m'aider à habiller les 2 lignes de code
reprise dans le bout de code ci-dessous.

Comme à chaque fois, je rame (après de nombreux essais) à placer les ",
'",

"""; "'", Chr(34) aux endroits corrects.

D'avance merci.

Set comZoom = CreateControl(Form.Name, acCommandButton, , , , 13100, 1000,
1300, 1000)
With comZoom
.Name = "comZoom"
.Caption = "ZOOM"
.OnClick = "[Procédure événementielle]"
Dim mdlZoom As Module
Set mdlZoom = Forms!Formulaire2.Module
Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom" & "_Click()" & vbCrLf _
& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt" &
Chr(34) & " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _
----------------------------------------------------------
--

-------------------------------------------------------------------
CE SONT LES 2 LIGNES QUI SUIVENT QUI ME CAUSENT PROBLEME
----------------------------------------------------------
--

------------------------------------------------------------------
& vbTab & "leTit = DLookup("[titulaire, "tbEmploi",
"[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _
& vbTab & "lHisto = DLookup("[DernierDetitulaireHisto]",
"tbEmploi", "[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _

& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub" _
mdl.InsertText chTexteZoom
End With




Avatar
Jessy Sempere [MVP]
Oups j'ai rippé.... ;-)))

Je disais donc, essais :

Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom_Click()" & vbCrLf _
& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt" & Chr(34)
& " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _
& vbTab & "leTit = DLookup(""[titulaire]"", ""tbEmploi"",
""[refEmploi] = Mid(ctrl.Name, 3, 3))""" & vbCrLf _
& vbTab & "lHisto = DLookup(""[DernierDetitulaireHisto]"",
""tbEmploi"", ""[refEmploi] = Mid(ctrl.Name, 3, 3))""" & vbCrLf _
& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub"


--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Jessy Sempere [MVP]" a écrit dans le message
news: c6t74t$j28$
Bonjour

Essais :



--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Hugo Degueldre" a écrit dans le message
news: 409217ca$0$25085$
Bonjour,

Un doué de la quote pourrait-il m'aider à habiller les 2 lignes de code
reprise dans le bout de code ci-dessous.

Comme à chaque fois, je rame (après de nombreux essais) à placer les ",
'",

"""; "'", Chr(34) aux endroits corrects.

D'avance merci.

Set comZoom = CreateControl(Form.Name, acCommandButton, , , , 13100,
1000,


1300, 1000)
With comZoom
.Name = "comZoom"
.Caption = "ZOOM"
.OnClick = "[Procédure événementielle]"
Dim mdlZoom As Module
Set mdlZoom = Forms!Formulaire2.Module
Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom" & "_Click()" & vbCrLf _
& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt" &
Chr(34) & " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _


----------------------------------------------------------

--
-------------------------------------------------------------------
CE SONT LES 2 LIGNES QUI SUIVENT QUI ME CAUSENT
PROBLEME



----------------------------------------------------------

--
------------------------------------------------------------------
& vbTab & "leTit = DLookup("[titulaire, "tbEmploi",
"[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _
& vbTab & "lHisto = DLookup("[DernierDetitulaireHisto]",
"tbEmploi", "[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _

& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub" _
mdl.InsertText chTexteZoom
End With








Avatar
Hugo Degueldre
Voilà le résultat : toujours une erreur de syntaxe mais malgré tout, bien
avancé


le résultat souhaité serait :

leTit = DLookup("[titulaire]", "tbEmploi", "[refEmploi] = " & Mid(ctrl.Name,
3, 3))
lHisto = DLookup("[DernierDetitulaireHisto]", "tbEmploi", "[refEmploi] = " &
Mid(ctrl.Name, 3, 3))

ton code donne (je passe les lignes qui fonctionnent)

leTit = DLookup("[titulaire]", "tbEmploi","[refEmploi] = Mid(ctrl.Name,
3, 3))"
lHisto = DLookup("[DernierDetitulaireHisto]","tbEmploi", "[refEmploi] Mid(ctrl.Name, 3, 3))"

C'est donc le dernier " qu'il faut déplacer en position après le = , puis
faire suivre de & avant le Mid

Suis désolé, mais moi ça me rend &"'&'cinglé&"&'

As-tu encore qq minutes ?

merci

hd
"Jessy Sempere [MVP]" a écrit dans le message
news: c6t77j$j2j$
Oups j'ai rippé.... ;-)))

Je disais donc, essais :

Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom_Click()" & vbCrLf _
& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt" &
Chr(34)

& " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _
& vbTab & "leTit = DLookup(""[titulaire]"", ""tbEmploi"",
""[refEmploi] = Mid(ctrl.Name, 3, 3))""" & vbCrLf _
& vbTab & "lHisto = DLookup(""[DernierDetitulaireHisto]"",
""tbEmploi"", ""[refEmploi] = Mid(ctrl.Name, 3, 3))""" & vbCrLf _
& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub"


--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Jessy Sempere [MVP]" a écrit dans le message
news: c6t74t$j28$
Bonjour

Essais :



--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"Hugo Degueldre" a écrit dans le message
news: 409217ca$0$25085$
Bonjour,

Un doué de la quote pourrait-il m'aider à habiller les 2 lignes de
code



reprise dans le bout de code ci-dessous.

Comme à chaque fois, je rame (après de nombreux essais) à placer les
",



'",
"""; "'", Chr(34) aux endroits corrects.

D'avance merci.

Set comZoom = CreateControl(Form.Name, acCommandButton, , , , 13100,
1000,


1300, 1000)
With comZoom
.Name = "comZoom"
.Caption = "ZOOM"
.OnClick = "[Procédure événementielle]"
Dim mdlZoom As Module
Set mdlZoom = Forms!Formulaire2.Module
Dim chTexteZoom As String
chTexteZoom = "Private Sub comZoom" & "_Click()" & vbCrLf
_



& vbTab & "Dim allControls" & vbCrLf _
& vbTab & "Dim ctrl As Control" & vbCrLf _
& vbTab & "Set allControls = Me.Controls" & vbCrLf _
& vbTab & "For Each ctrl In allControls" & vbCrLf _
& vbTab & "If Left(ctrl.Name, 2) = " & Chr(34) & "bt"
&



Chr(34) & " Then" & vbCrLf _
& vbTab & "Dim leTit, lHisto" & vbCrLf _


----------------------------------------------------------

--
-------------------------------------------------------------------
CE SONT LES 2 LIGNES QUI SUIVENT QUI ME CAUSENT
PROBLEME



----------------------------------------------------------

--
------------------------------------------------------------------
& vbTab & "leTit = DLookup("[titulaire, "tbEmploi",
"[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _
& vbTab & "lHisto DLookup("[DernierDetitulaireHisto]",
"tbEmploi", "[refEmploi] = " & Mid(ctrl.Name, 3, 3))" & vbCrLf _

& vbTab & "If leTit = lHisto Then" & vbCrLf _
& vbTab & "ctrl.ForeColor = vbYellow" & vbCrLf _
& vbTab & "Else" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "ctrl.FontSize = 9" & vbCrLf _
& vbTab & "End If" & vbCrLf _
& vbTab & "Next ctrl" & vbCrLf _
& vbTab & "End Sub" _
mdl.InsertText chTexteZoom
End With