Faiblesse en VB? qui poura repondre?
trezeg
-
trezeg -
trezeg -
Bonjour à tous , voilà le pbme! normalement ce code fonctionne sous access 2 mais plus sous access 2000! qui poura essayer de trouver les reponses? je met des ?? aux niveaux des pbmes
Private Sub Exécuter_Compétenc_Click()
On Error GoTo Err_Exécuter_Compétenc_Click
Dim MonSQL As String, MonCritère As String
Dim MaBD As Variant, MaTable As ?? Recordset??
' **** Efface le contenu du fichier Extrait COMPETENCES *******************
MonSQL = "DELETE * FROM [Extrait COMPETENCES]"
DoCmd.RunSQL MonSQL
' **** Crée une requête pour faire une extraction de COMPETENCES *********
Set MaBD = DBEngine.Workspaces(0).Databases(0)
Set MaTable = MaBD.??OpenRecordset??("Sél COMPETENCES", DB_OPEN_DYNASET)
MaTable.MoveFirst
Do Until MaTable.EOF
If MaTable![NOM DE LA SELECTION] = [NOM DE LA SELECTION] Then
MonSQL = "INSERT INTO [Extrait COMPETENCES] SELECT [COMPETENCES].* FROM [COMPETENCES] WHERE "
MonSQL = MonSQL & "[COMPETENCES]![UA Comp] Like " & """*"""
' #### sélection LIBELLE COMPETENCE ####
If MaTable![LIBELLE COMPETENCE] = "*" Then
MonSQL = MonSQL
ElseIf IsNull(MaTable![LIBELLE COMPETENCE]) Then
MonSQL = MonSQL & " And [COMPETENCES]![LIBELLE COMPETENCE] Is Null"
Else
MonSQL = MonSQL & " And [COMPETENCES]![LIBELLE COMPETENCE] Like """ & MaTable![LIBELLE COMPETENCE] & """"
End If
' #### sélection NIVEAU ####
If MaTable![NIVEAU] = "" Or IsNull(MaTable![NIVEAU]) Or MaTable![NIVEAU] = 99999 Then
MonSQL = MonSQL
ElseIf IsNull(MaTable![NIVEAU]) Then
MonSQL = MonSQL & " And [COMPETENCES]![NIVEAU] Is Null"
Else
MonSQL = MonSQL & " And [COMPETENCES]![NIVEAU] = " & MaTable![NIVEAU]
End If
DoCmd.RunSQL MonSQL
End If
MaTable.MoveNext
Loop
MaTable.Close
Exit_Exécuter_Compétenc_Click:
Exit Sub
Err_Exécuter_Compétenc_Click:
MsgBox Error$
Resume Exit_Exécuter_Compétenc_Click
End Sub
Merci d avance pour les best du visual basic! sinon pr les tables et requetes aucun pbme, dc ça ne vient pas de là!
à bientot trezeg
Private Sub Exécuter_Compétenc_Click()
On Error GoTo Err_Exécuter_Compétenc_Click
Dim MonSQL As String, MonCritère As String
Dim MaBD As Variant, MaTable As ?? Recordset??
' **** Efface le contenu du fichier Extrait COMPETENCES *******************
MonSQL = "DELETE * FROM [Extrait COMPETENCES]"
DoCmd.RunSQL MonSQL
' **** Crée une requête pour faire une extraction de COMPETENCES *********
Set MaBD = DBEngine.Workspaces(0).Databases(0)
Set MaTable = MaBD.??OpenRecordset??("Sél COMPETENCES", DB_OPEN_DYNASET)
MaTable.MoveFirst
Do Until MaTable.EOF
If MaTable![NOM DE LA SELECTION] = [NOM DE LA SELECTION] Then
MonSQL = "INSERT INTO [Extrait COMPETENCES] SELECT [COMPETENCES].* FROM [COMPETENCES] WHERE "
MonSQL = MonSQL & "[COMPETENCES]![UA Comp] Like " & """*"""
' #### sélection LIBELLE COMPETENCE ####
If MaTable![LIBELLE COMPETENCE] = "*" Then
MonSQL = MonSQL
ElseIf IsNull(MaTable![LIBELLE COMPETENCE]) Then
MonSQL = MonSQL & " And [COMPETENCES]![LIBELLE COMPETENCE] Is Null"
Else
MonSQL = MonSQL & " And [COMPETENCES]![LIBELLE COMPETENCE] Like """ & MaTable![LIBELLE COMPETENCE] & """"
End If
' #### sélection NIVEAU ####
If MaTable![NIVEAU] = "" Or IsNull(MaTable![NIVEAU]) Or MaTable![NIVEAU] = 99999 Then
MonSQL = MonSQL
ElseIf IsNull(MaTable![NIVEAU]) Then
MonSQL = MonSQL & " And [COMPETENCES]![NIVEAU] Is Null"
Else
MonSQL = MonSQL & " And [COMPETENCES]![NIVEAU] = " & MaTable![NIVEAU]
End If
DoCmd.RunSQL MonSQL
End If
MaTable.MoveNext
Loop
MaTable.Close
Exit_Exécuter_Compétenc_Click:
Exit Sub
Err_Exécuter_Compétenc_Click:
MsgBox Error$
Resume Exit_Exécuter_Compétenc_Click
End Sub
Merci d avance pour les best du visual basic! sinon pr les tables et requetes aucun pbme, dc ça ne vient pas de là!
à bientot trezeg
3 réponses
-
-
- Tu dois aller dans l'editeur de code VBA
- Dans le menu "Tools" / "Outils"
- Et la tu as references
- Retire "Ole automation"
- Rajoute "Microsoft DAO 2.5 ..... compatibility"
- Si ca marche essaye de passer a un DAO superieur
De preference, sauvegarde ta Bdd avant d'essayer toutes modifications. Ca me donnera bonne conscience en cas de pépin (nul ne sait ce que Microsoft nous reserve comme mauvaise surprise :-) -
Remarque qui n'a rien avoir ou presque
IL NE FAUT JAMAIS UTILISE DES ACCENTS DANS LA PROGRAMMATION.
Ce n'est pas la peine de rajouter des risques de probleme pour programmer.
Suicidaire va
Si on me demande de debugger un prog et que je vois des accents, je prefere le recommencer entierement