Hi, well I'm using VB and Access as the db. I have made a crosstab
query in Access and it's work well, but when I do the same in VB
through ADO (not the control) it doesn't work.
I've just copied the SQL sentence as appear in Access to VB as
something like:
dim rs as ADODB.Recordset
str_sql = "crosstab query" ' this is the SQL sentence as appear in
Access
' conn is a ADODB.Connection already set
Call rs.Open(str_sql, conn, adOpenStatic, adLockOptimistic)
' I've tried with adOpenDynamic too, but I haven't gotten the correct
result
When I run that, the result is not that in Access is, the result with
ADO and VB give me only 3 fields -columns- (in Access are about 120
fields), I mean VB and ADO just show me the fields that in Access are
labeled as "row header" (well I don't know if this label is right
because I have the spanish version of Access and I don't know if this
is traslated this way in the english version), and those fields that
are showed by VB are completely empty.
Can not ADO handle crosstab queries? or what am I doing wrong?
Thanks in advanced
Michael B. Johnson - 27 Nov 2006 19:29 GMT
>Hi, well I'm using VB and Access as the db. I have made a crosstab
>query in Access and it's work well, but when I do the same in VB
>through ADO (not the control) it doesn't work.
<snipped/>
>When I run that, the result is not that in Access is, the result with
>ADO and VB give me only 3 fields -columns- (in Access are about 120
[quoted text clipped - 5 lines]
>
>Can not ADO handle crosstab queries? or what am I doing wrong?
AFAIK, ADO will not run MS Access PIVOT queries using only the name of the MS
Access queries. You'll need to view the query as SQL, copy that into a VB
string, then use than in your call to "rs.Open".
If you don't want to copy the PIVOT text and run the query using its SQL
equivalent, then you may want to use DAO.
_______________________
Michael B. Johnson