Running a query and putting the result in to a variable

Ø

Øystein 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
 
J

JohnFol

You would need to open a recordset.

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

Michel Walsh

Hi,


just:


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



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top