Envoyé par
ptisinge
voila j'ai une form avec une sub form
dans vb je fais une requete qui doit mettre a jour la subform en fonction des parametre que l'on a saisi dans la form mais ce ne marche pas
pourtant je fais un requery mais ca ne donne rien
voila mon code
merci pour votre aide
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
| Option Compare Database
Private Sub refresh_Command_Click()
Dim cp As Variant
Comp.Value = ComboComp.Value
Cat.Value = ComboCat.Value
If ExistQuery("QContact") Then CurrentDb.QueryDefs.Delete "QContact"
If IsNull(Comp.Value) And IsNull(Cat.Value) = False Then
SQLQ1 = "SELECT * FROM contacts WHERE contacts.Category=Forms![Contact Form]!cat;"
Dim qdf As QueryDef
Set qdf = CurrentDb.CreateQueryDef("QContact", SQLQ1)
ElseIf IsNull(Comp.Value) = False And IsNull(Cat.Value) = True Then
SQLQ2 = "SELECT * FROM contacts WHERE contacts.Company=Forms![Contact Form]!comp;"
Dim qdf2 As QueryDef
Set qdf2 = CurrentDb.CreateQueryDef("QContact", SQLQ2)
ElseIf IsNull(Comp.Value) = False And IsNull(Cat.Value) = False Then
SQLQ3 = "SELECT * FROM contacts WHERE contacts.company=Forms![Contact Form]!comp and contacts.category=Forms![Contact Form]!cat;"
Dim qdf3 As QueryDef
Set qdf3 = CurrentDb.CreateQueryDef("QContact", SQLQ3)
End If
Me.RecordSource = Me.RecordSource
Me![QContact subform].Requery
Forms("Contact Form").Refresh
End Sub |
Ton problème se situe peut être au niveau de la chaine sql
au lieu de
"SELECT * FROM contacts WHERE contacts.Category=Forms![Contact Form]!cat;"
il faut (je pense bien)
"SELECT * FROM contacts WHERE contacts.Category=" & Forms![Contact Form]!cat & ";"
si le champs category est de type numérique.
sinon
"SELECT * FROM contacts WHERE contacts.Category='" & Forms![Contact Form]!cat & "';"
si le champs est de type texte
Partager