Hi
The database is pretty big but I can show you the line that updates the queries upon changing the values of the combo box (see
http://www.access-programmers.co.uk/forums/showthread.php?t=155755)
Here is the function that I use and where the requery is asked :
Private Function UpdateFields()
Dim strSQL As String
strSQL = "1=1"
If IsNull(Me.cboPO) = True Then
If IsNull(Me.cboProject) = False Then
strSQL = "tblCommandes.NoUltragen = [Forms]![frmSelection]![cboProject]" & "AND"
ElseIf IsNull(Me.cboClient) = False Then
If Right(strSQL, 3) <> "AND" Then
strSQL = "tblCommandes.Client = [Forms]![frmSelection]![cboClient]"
Else
strSQL = strSQL & "tblCommandes.Client = [Forms]![frmSelection]![cboClient]" & "AND"
End If
ElseIf IsNull(Me.cboNom) = False Then
If Right(strSQL, 3) <> "AND" Then
strSQL = "tblCommandes.Nom = [Forms]![frmSelection]![cboNom]"
Else
strSQL = strSQL & "tblCommandes.Nom = [Forms]![frmSelection]![cboNom]" & "AND"
End If
ElseIf IsNull(Me.cboDiscipline) = False Then
If Right(strSQL, 3) <> "AND" Then
strSQL = "tblFournisseurs.Discipline = [Forms]![frmSelection]![cboDiscipline]"
Else
strSQL = strSQL & "tblFournisseurs.Discipline = [Forms]![frmSelection]![cboDiscipline]" & "AND"
End If
ElseIf IsNull(Me.cboFamille) = False Then
If Right(strSQL, 3) <> "AND" Then
strSQL = "tblFournisseurs.Famille = [Forms]![frmSelection]![cboFamille]"
Else
strSQL = strSQL & "tblFournisseurs.Famille = [Forms]![frmSelection]![cboFamille]" & "AND"
End If
End If
If Right(strSQL, 3) = "AND" Then
strSQL = Left(strSQL, Len(strSQL) - 3)
End If
Else
strSQL = "tblCommandes.PO = [Forms]![frmSelection]![cboPO]"
End If
strSQL = "SELECT tblCommandes.PO, tblCommandes.[OR], tblCommandes.NoUltragen, tblCommandes.Client, tblCommandes.NoClient, tblCommandes.Nom, tblCommandes.Description, tblCommandes.ValeurPO, tblCommandes.ValeurREAL, [ValeurReal]-[ValeurPO] AS ValeurDiff, tblCommandes.LivraisonPrévu, tblCommandes.DateButoir, tblCommandes.LivraisonREAL, CalcWorkdays([LivraisonPrévu],[LivraisonREAL]) AS LivraisonDiff, tblCommandes.NoReception, tblCommandes.[Conformité Tech], tblCommandes.[Service QLTY], tblCommandes.[Service Ap/V], tblCommandes.Suivit, tblCommandes.Soumission, tblCommandes.Docs, tblCommandes.DocsLink, tblFournisseurs.Discipline, tblFournisseurs.Famille" & _
" FROM tblCommandes INNER JOIN tblFournisseurs ON tblCommandes.Nom = tblFournisseurs.ID" & " WHERE " & strSQL
'Where((tblCommandes.NoUltragen =[Forms]![frmSelection]![cboProject] OR [Forms]![frmSelection]![cboProject] is null )
'AND (tblCommandes.Client = [Forms]![frmSelection]![cboClient] OR [Forms]![frmSelection]![cboClient] is null)
'AND (tblCommandes.Nom = [Forms]![frmSelection]![cboNom] OR [Forms]![frmSelection]![cboNom] is null)
'AND (tblFournisseurs.Discipline = [Forms]![frmSelection]![cboDiscipline] OR [Forms]![frmSelection]![cboDiscipline] is null )
'AND (tblFournisseurs.Famille = [Forms]![frmSelection]![cboFamille] OR [Forms]![frmSelection]![cboFamille] is null ))
'OR (tblCommandes.PO = [Forms]![frmSelection]![cboPO]);"
CurrentDb.QueryDefs("qrySelection").SQL = strSQL
Forms![frmSelection]!sfrmSelection.Form.Requery
'Me.sfrmSelection.Requery
Me.Text14.Value = 0
Me.Text14.Value = DSum("ValeurREAL", "qrySelection")
Me.Text14.Requery
Me.Text16.Value = DAvg("[Service QLTY]", "[qrySelection]")
Me.Text16.Requery
Me.Text18.Value = DAvg("[Service ap/v]", "[qrySelection]")
Me.Text18.Requery
Me.Text24.Value = DSum("ValeurPO", "qrySelection")
Me.Text24.Requery
End Function
Any idea where is the problem?
Thanks