requete sql en vba avec un select MAX
Bonjour, j'ai fais une requete SQL en VBA sur une table
je fais un select sur 2 champs dont le premier champs avec MAX
mais mon select max ne fonctionnes pas
si j'enleve le deuxieme champs ca fonctionnes ([TBL_SOLID_SOUS_PIECE].[MP])
il me dit que l'item nest pas trouvé
merci d'avance pour de l'aide
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Dim dbs As Database
Dim rst As Recordset
Dim SORT_VAR, SORT_VAR1, SORT_VAR2
SORT_VAR1 = "SELECT MAX([TBL_SOLID_SOUS_PIECE].[SP]), [TBL_SOLID_SOUS_PIECE].[MP] FROM [TBL_SOLID_SOUS_PIECE]"
SORT_VAR2 = " WHERE ((([TBL_SOLID_SOUS_PIECE].[MP]) = '" & test & "'))"
SORT_VAR = SORT_VAR1 & SORT_VAR2
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(SORT_VAR)
With rst
Item = ![SP]
.Close
End With 'rst
msgbox(Item) |
Alex