adrix69
Messages postés6Date d'inscriptionmardi 6 juin 2006StatutMembreDernière intervention21 avril 2009
-
6 juin 2006 à 10:53
adrix69
Messages postés6Date d'inscriptionmardi 6 juin 2006StatutMembreDernière intervention21 avril 2009
-
6 juin 2006 à 16:10
bonjour tout le monde, je suis débutant sur vb pourriez vous me dire pourquoi ma requéte ne marche pas merci
Private Sub Commande27_Click()
On Error GoTo Err_Commande27_Click
'
Dim strCmd As String
Dim nspCmd As Integer
Dim gsiCmd As Integer
Dim gedasCmd As Integer
Dim laspCmd As Integer
Dim opacCmd As Integer
'
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Formulaire des procédures"
' If Me.ref_logiciel 1 And Me.Choix_tous False Then
If Me.Choix_nsp = True Then
nspCmd = 2
End If
If Me.Choix_gsi = True Then
gsiCmd = 1
End If
If Me.Choix_opac = True Then
opacCmd = 5
End If
If Me.Choix_lasp = True Then
laspCmd = 4
End If
If Me.Choix_gedas = True Then
gedasCmd = 3
End If
strCmd = "SELECT procedure.[procedure], procedure.[ref_logiciel], procedure.[ref_type] FROM [procedure]WHERE (((procedure.[ref_logiciel])='1') AND ((procedure.[ref_type])=" & gsiCmd & " Or (procedure.[ref_type])= " & nspCmd & " Or (procedure.[ref_type])= " & gedasCmd & " Or (procedure.[ref_type])= " & laspCmd & " Or (procedure.[ref_type])= " & opacCmd & " ));"
Forms![Formulaire des procédures].RecordSource = strCmd
End If
adrix69
Messages postés6Date d'inscriptionmardi 6 juin 2006StatutMembreDernière intervention21 avril 2009 6 juin 2006 à 11:44
voici le nouveau code
Private Sub Commande27_Click()
On Error GoTo Err_Commande27_Click
Dim SQL As String
Dim nspCmd As String
Dim gsiCmd As String
Dim gedasCmd As String
Dim laspCmd As String
Dim opacCmd As String
'
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Formulaire des procédures"
' If Me.ref_logiciel 1 And Me.Choix_tous False Then
SQL = "SELECT procedure.procedure, procedure.ref_logiciel, procedure.ref_type, procedure.result_att, procedure.titre, procedure.result_obt, procedure.conclusion, procedure.refpro FROM [procedure] WHERE (((procedure.ref_logiciel)='1'))"
If Me.Choix_nsp Then SQL SQL & "Or procedure!ref_type '*" & nspCmd & "*' "
End If
If Me.Choix_gsi Then SQL SQL & "Or procedure!ref_type '*" & gsiCmd & "*' "
End If
If Me.Choix_opac Then SQL SQL & "Or procedure!ref_type '*" & opacCmd & "*' "
End If
If Me.Choix_lasp Then SQL SQL & "Or procedure!ref_type '*" & laspCmd & "*' "
End If
If Me.Choix_gedas Then SQL SQL & "Or procedure!ref_type '*" & gedasCmd & "*' "
End If
SQL = SQL & ";"
Forms![Formulaire des procédures].RecordSource = SQL
adrix69
Messages postés6Date d'inscriptionmardi 6 juin 2006StatutMembreDernière intervention21 avril 2009 6 juin 2006 à 16:10
Voila mon code qui marche mais maintenant j'ai un nouveau probleme, j'aimerais ouvrir un etat avec la requéte SQL qui est généré dans ce code, comment faire svp??
<hr />
Private Sub Commande27_Click()
On Error GoTo Err_Commande27_Click
Dim SQL As String
Dim cmd As Boolean
'
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Formulaire des procédures"
' If Me.ref_logiciel 1 And Me.Choix_tous False Then
SQL = "SELECT procedure.procedure, procedure.ref_logiciel, procedure.ref_type, procedure.result_att, procedure.titre, procedure.result_obt, procedure.conclusion, procedure.refpro FROM [procedure] WHERE (((procedure.ref_logiciel)='1'))"
cmd = False
If Me.Choix_nsp Then
If cmd = True Then SQL SQL & " Or procedure.ref_type '2'"
Else
cmd = True SQL SQL & " And (procedure.ref_type '2'"
End If
End If
If Me.Choix_gsi Then
If cmd = True Then SQL SQL & " Or procedure.ref_type '1'"
Else
cmd = True SQL SQL & " And (procedure.ref_type '1'"
End If
End If
If Me.Choix_opac Then
If cmd = True Then SQL SQL & " Or procedure.ref_type '5'"
Else
cmd = True SQL SQL & " And (procedure.ref_type '5'"
End If
End If
If Me.Choix_lasp Then
If cmd = True Then SQL SQL & " Or procedure.ref_type '4'"
Else
cmd = True SQL SQL & " And (procedure.ref_type '4'"
End If
End If
If Me.Choix_gedas Then
If cmd = True Then SQL SQL & " Or procedure.ref_type '3'"
Else
cmd = True SQL SQL & " And (procedure.ref_type '3'"
End If
End If
If cmd = True Then
SQL = SQL & ")"
End If
SQL = SQL & ";"
Forms![Formulaire des procédures].RecordSource = SQL
End If