Vba access: retrieve a specific value
Solved
arzawe
Posted messages
71
Status
Member
-
Funstenolf -
Funstenolf -
Hello,
I am looking to retrieve a specific value from a table with the following formula:
sql = "SELECT [Ratios]![HMO total] FROM [Ratios] WHERE [Ratios]![Ligne] = 'TOTAL - U2"
MsgBox = sql
But what it gives me in my msgbox is my formula. What I want is the number it corresponds to in the table.
What is missing in my formula?
Thank you for your help
--
Arzawe
I am looking to retrieve a specific value from a table with the following formula:
sql = "SELECT [Ratios]![HMO total] FROM [Ratios] WHERE [Ratios]![Ligne] = 'TOTAL - U2"
MsgBox = sql
But what it gives me in my msgbox is my formula. What I want is the number it corresponds to in the table.
What is missing in my formula?
Thank you for your help
--
Arzawe
Configuration: Windows XP Internet Explorer 6.0
6 answers
-
variable :
Dim requete As Recordset
Dim sql As String
Dim resultat As Currency
code d'exécution de la requête :
sql = " SELECT champ1, champ2, ... FROM table WHERE ... ;"
Set requete = CurrentDb.OpenRecordset(sql)
première ligne de résultat :
requete.MoveFirst
resultat = requete("champ1")
et enfin tu affiches resultat
Voilà