ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using ADO Recorsets in sql SELECT sentence (https://www.excelbanter.com/excel-programming/398675-using-ado-recorsets-sql-select-sentence.html)

sharon

Using ADO Recorsets in sql SELECT sentence
 
Hi,

I'm very new in SQL and VBa, so maybe it's very simple, but I'm not being
able to use one or more Recordsets in a SQL SELECT sentence.

Having 2 recordsets (opened) what I need is to relate them in a sql
populating a new recordset....
....
rsOne
rsTwo

ssql="SELECT rsOne!Field1,rsOne!Field2,rsTwo!Field1 FROM rsOne,rsTwo WHERE
rsOne!Field1=rsTwo!Field1"
rsThree.open cnn,,,adcmtext

But this gives me an error saying Microsoft Jet can't find rsOne object.

What I'm doing wrong?

Thanks for your help,





Keithlo

Using ADO Recorsets in sql SELECT sentence
 
If you're using MS Access, or if you can use MS Access on your data just to
find the error, try using the graphical tools to do what you want to do and
then review the SQL that it creates. If you right-click the down arrow by
the View button in the upper right, one of the choices should be SQL View.

Sometimes it is not possible to use the graphical tools to create what you
want, and in that case my suggestion won't help you, but what you're
describing looks like a Select query relating two tables, and that can be
done using the graphical tools.

Hope this helps.

Keith

"sharon" wrote:

Hi,

I'm very new in SQL and VBa, so maybe it's very simple, but I'm not being
able to use one or more Recordsets in a SQL SELECT sentence.

Having 2 recordsets (opened) what I need is to relate them in a sql
populating a new recordset....
...
rsOne
rsTwo

ssql="SELECT rsOne!Field1,rsOne!Field2,rsTwo!Field1 FROM rsOne,rsTwo WHERE
rsOne!Field1=rsTwo!Field1"
rsThree.open cnn,,,adcmtext

But this gives me an error saying Microsoft Jet can't find rsOne object.

What I'm doing wrong?

Thanks for your help,





sharon

Using ADO Recorsets in sql SELECT sentence
 
Keithlo ,

Thanks for your answer. In fact, I'm working over FoxPro data tables, in
different folders, and this (AFAIK) makes unfeasible your point.

So far, I decided to create new recordsets hopping I could be able to relate
them in a single new sql sentence. But I can't find out how to referenciate
these recordsets in the sql string sentence. If possible...(I guess it is..)

Regards,



"Keithlo" wrote:

If you're using MS Access, or if you can use MS Access on your data just to
find the error, try using the graphical tools to do what you want to do and
then review the SQL that it creates. If you right-click the down arrow by
the View button in the upper right, one of the choices should be SQL View.

Sometimes it is not possible to use the graphical tools to create what you
want, and in that case my suggestion won't help you, but what you're
describing looks like a Select query relating two tables, and that can be
done using the graphical tools.

Hope this helps.

Keith

"sharon" wrote:

Hi,

I'm very new in SQL and VBa, so maybe it's very simple, but I'm not being
able to use one or more Recordsets in a SQL SELECT sentence.

Having 2 recordsets (opened) what I need is to relate them in a sql
populating a new recordset....
...
rsOne
rsTwo

ssql="SELECT rsOne!Field1,rsOne!Field2,rsTwo!Field1 FROM rsOne,rsTwo WHERE
rsOne!Field1=rsTwo!Field1"
rsThree.open cnn,,,adcmtext

But this gives me an error saying Microsoft Jet can't find rsOne object.

What I'm doing wrong?

Thanks for your help,





Tim Williams

Using ADO Recorsets in sql SELECT sentence
 
ADO doesn't work like that: recordsets can't be queried using SQL as though
they were tables.
You need to get your records into tables in the same database (or you could
dump them into named ranges in a worksheet...)

Tim


"sharon" wrote in message
...
Hi,

I'm very new in SQL and VBa, so maybe it's very simple, but I'm not being
able to use one or more Recordsets in a SQL SELECT sentence.

Having 2 recordsets (opened) what I need is to relate them in a sql
populating a new recordset....
...
rsOne
rsTwo

ssql="SELECT rsOne!Field1,rsOne!Field2,rsTwo!Field1 FROM rsOne,rsTwo WHERE
rsOne!Field1=rsTwo!Field1"
rsThree.open cnn,,,adcmtext

But this gives me an error saying Microsoft Jet can't find rsOne object.

What I'm doing wrong?

Thanks for your help,








All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com