result of query in recordset

G

Geert Annys

Hi,


is it possible to put the result of a SQL-query in a recordset?
If so, what's the right way to go about this? I can't seem to find anything
in the Access-help.
What I want to do is select values from a table with a SQL query (SELECT *
FROM tblValveList WHERE Like '*V2*')

I use this query as recordsource for a Form and this works.
But I want to put it into a variable so that I can use it to select the
values and put it in a Listbox for example.

Do I use 'Recordset' for this and how do I use it?

Thanks in advance


Geert
 
T

Tom Ellison

Dear Geert:

Your desired query is:

SELECT * FROM tblValveList WHERE Like '*V2*

and you want to place the results in a variable.

Here are some comments about this:

- your query doesn't work as written. Your where clause needs to be:

WHERE <some column> Like '*V2*'

- Your query may return several rows and several columns. You must
choose one, and only one row and column if you want to place the
result in a simple variable.

What you want to perform here may be easiest for you to do with a
DLookup. See online help for this function. Perhaps you should type
in the code:

YourVariable = DLookup(

Put the cursor on DLookup and press F1.

Hi,


is it possible to put the result of a SQL-query in a recordset?
If so, what's the right way to go about this? I can't seem to find anything
in the Access-help.
What I want to do is select values from a table with a SQL query (SELECT *
FROM tblValveList WHERE Like '*V2*')

I use this query as recordsource for a Form and this works.
But I want to put it into a variable so that I can use it to select the
values and put it in a Listbox for example.

Do I use 'Recordset' for this and how do I use it?

Thanks in advance


Geert

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 

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