Solved

SQL Query Syntax Error

Posted on 2009-07-07
2
262 Views
Last Modified: 2013-11-16
Hello.

I need to make a dynamic query to RSMain based on the RSIndex id_indexador. But its not working this way...

Please help!

Thanks in advance!

comando = "SELECT * FROM tbl_Indexador" 

call abrers(comando, "listar", RSIndex)
 

DO WHILE NOT RSIndex.EOF 

comando = "SELECT * FROM tbl_Cotacao where dt_cotacao = '"&dt&"' and id_indexador = "& RSIndex("id_indexador")

call abrers(comando, "listar", RSMain&RSIndex("id_indexador"))

RSIndex.MoveNext

loop

Open in new window

0
Comment
Question by:drix76
  • 2
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24793335
what about combining this into 1 query:
comando = "SELECT * FROM tbl_Cotacao where dt_cotacao = '"&dt&"' and id_indexador IN ( select id_indexador FROM tbl_Indexador ) "
call abrers(comando, "listar", RSIndex)

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24793340
apart from that: what error do you get, on which line, etc ..?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now