Running a query and putting the result in to a variable

  • Thread starter Thread starter =?ISO-8859-1?Q?=D8ystein_Sund?=
  • Start date Start date
?

=?ISO-8859-1?Q?=D8ystein_Sund?=

Hello

I've made the following in VBA:
Dim query As String
Dim result
query = "SELECT value FROM settings WHERE description = 'priceperhour'"
DoCmd.RunSQL query


There is one row with the description cell = priceperhour and the value
cell = 350.
How do I put the value cell into the variable result?


Any help would be appreciated!

Sincerely
Øystein Sund
 
You would need to open a recordset.

Alternatively use a DLookup
Dim iValueCell as Integer
iValueCell = DLookup("Value", "Settings", "description = 'priceperhour'")
 
Hi,


just:


Dim Result As Variant
Result=DLookup("value", "Settings", "Description='priceperhour' " )



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top