2 pièce(s) jointe(s)
Difficulté avec INSERT INTO
Bonjour membres du forum !
Permettez moi d'ouvrir la 2e partie de la discussion concernant mon application "Usine à gaz" :ptdr: https://www.developpez.net/forums/d1...ublons-access/
Bref ! Voici l'erreur qui survient après clique sur la commande "GENERER..."
Code:
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
| Private Sub cmdInitialiser_Click()
On Error GoTo OUMAR
If IsNull(Me.ID_ETABL_FREQ) Or Me.ID_ETABL_FREQ = "" Then
If MsgBox("Selectionnez le Nom de l'ETABLISSEMENT!", vbOKOnly, "ENTREZ LES PARAMETRES") = vbCancel Then Exit Sub
End If
If IsNull(Me.ANNEE_SCOLNivScol) Or Me.ANNEE_SCOLNivScol = "" Then
If MsgBox("Selectionnez le Nom de l'ANNEE_SCOL!", vbOKOnly, "ENTREZ LES PARAMETRES") = vbCancel Then Exit Sub
End If
If IsNull(Me.bCocher) Or Me.bCocher = 0 Then
If MsgBox("Cochez la boîte Cocher à bCocher !", vbOKOnly, "ENTREZ LES PARAMETRES") = vbCancel Then Exit Sub
End If
If Not IsNull(Me.ID_ETABL_FREQ) And Not IsNull(Me.ANNEE_SCOLNivScol) And Me.bCocher = -1 Then
DoCmd.SetWarnings False
'Me.bCocher = -1
AjouterEleveComposant Me.ID_ETABL_FREQ, Me.ANNEE_SCOLNivScol, Me.Num_Inscription, Me.Mleeleve
'Me.bCocher = 0
Me.Requery
DoCmd.SetWarnings True
End If
Exit Sub
OUMAR:
MsgBox err.description, vbExclamation + vbOKOnly, err.Number
End Sub |
Pièce jointe 471211
Code:
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
|
Sub AjouterEleveComposant(idEtab As Long, Ansco As String, NuminsEl As Long, MlElev As Long)
On Error GoTo OUMAR
Dim BD As Database
Dim RS As Recordset
Dim sql As String
Set BD = CurrentDb
DoCmd.SetWarnings False
sql = "select * from [Eleve_INSCRIT_Req_Plus] where ID_ETABL_FREQ =" & idEtab & "and ANNEE_SCOLNivScol='" & Ansco & "'and Num_Inscription=" & NuminsEl & "and Mleeleve=" & MlElev & "and bCocher order by Num_Inscription ;"
Set RS = BD.OpenRecordset(sql)
Set RS = BD.OpenRecordset(sql)
With RS
If .EOF Then
Else
.MoveFirst
Do While Not .EOF
sql = "INSERT INTO Tbl_EVALUATION_NIVEAU_SCOLAIRE" _
& "(NumEnregistreComposant, IdEcole,AnneeScol,NumInsCreleve, MleEleve, Nom_Prenoms_EleveComposant,COMPOSITION, NiveauCompositionFrancais) VALUES(" _
& f_NumAutoEnregistrementElevesComposants() + 1 & "," _
& Me.ID_ETABL_FREQ & "; " _
& Me.ANNEE_SCOLNivScol & "'," _
& Me.Num_Inscription & "," _
& Me.Mleeleve & ",'" _
& RS.Fields("NPrenomsEleves") _
& "', " & Me.Evaluation_Txt _
& ", '" & Me.NIVEAU__EVALUATION_Txt & ";)"
DoCmd.RunSQL sql
.MoveNext
Loop
End If
End With
DoCmd.SetWarnings True
Forms("Frm_EvaluationScolaireElevesECIND").Tbl_EVALUATION_NIVEAU_SCOLAIRE_SFrm.Requery
Exit Sub
OUMAR:
MsgBox err.description, vbExclamation, err.Number
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Private Sub OptionChoix_Click()
If Me.OptionChoix.Value = 1 Then
Me.cmdInitialiser.Visible = True
Else
Me.cmdInitialiser.Visible = False
End If
End Sub
Private Sub btAucun_Click()
On Error Resume Next
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Eleve_INSCRIT_Req_Plus SET bCocher=0;"
Me.Requery
End Sub
Private Sub btTous_Click()
On Error Resume Next
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE Eleve_INSCRIT_Req_Plus SET bCocher=-1;"
Me.Requery
End Sub |
Tous les codes ci dessus concernent le 2e sous formulaire "Frm_EvaluationScolaireElevesECIND_ChoisirComposants".
Pièce jointe de mon application.
Cordialement.
Difficulté avec INSERT INTO
Hello!
Je note également qu'il n'y a pas d'espace avant tes "AND" dans les SQL.