Toubles on reading data from tables using SQL-query

  • Thread starter Andriy O. Beregovenko
  • Start date
A

Andriy O. Beregovenko

HI
I have a table named as "optable", like this:
+--------+--------+
| option | value |
+--------+--------+
| opt1 | 1 |
| opt2 | 0 |
+--------+--------+
I want to execute SQL-query on it like this : " SELECT value FROM optable
WHERE option='opt1'; "...Help me ... I write to this table data using
SQL-query and DoCmd.RunSQL function, but i don't know how to read data from
it.Plz, write a example code howto read data from table using VBA. Main
trouble
is in to read data from table using SQL-query. I want to read data from
table using SQL-query as easy as posible...VBA code is a standart event
for the button click
 
A

Alex Dybenko

you have to open recordset:

dim rst as dao.recordset
set rst=currentdb.openrecordset("SELECT value FROM optable WHERE
option='opt1'; ")
if not rst.eof then
msgbox rst!Value & ""
end if
rst.close
 

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