Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easy - but not!? SQL placed into RecordSource property
Message
From
07/10/2004 10:46:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/10/2004 10:18:57
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00949531
Message ID:
00949548
Views:
12
This message has been marked as a message which has helped to the initial question of the thread.
>The following SQL query works flawlessly for me...
>
>
>
>SELECT company.company,company.address FROM ;
>company WHERE company.cidcomp in ;
>(SELECT DISTINCT Company.cidcomp FROM company INNER JOIN ;
>kent!compdesc ON  Company.cidcomp = Compdesc.cidcomp INNER JOIN ;
>kent!descrips ON  Compdesc.ciddesc = Descrips.ciddesc INNER JOIN ;
>kent!sectorline ON  Descrips.naics = Sectorline.naics INNER JOIN ;
>kent!sector ON Sectorline.cidsect = Sector.cidsect WHERE  ;
>Sector.sector = ( 'Manufacturing' )) ORDER BY company.company
>
>
>
>Now, I need to be able to dynamically place this code into the RecordSource property of a control on my form, but I keep getting an error that "Command contains unrecoginized phrase/keyword." The code I am using is as follows (in the LostFocus event of a ComboBox on the form)
>
>
>
>thisform.olecontrol1.recordsource =" SELECT company.company,company.address FROM ;
>company WHERE company.cidcomp in ;
>(SELECT DISTINCT Company.cidcomp FROM company INNER JOIN ;
>kent!compdesc ON  Company.cidcomp = Compdesc.cidcomp INNER JOIN ;
>kent!descrips ON  Compdesc.ciddesc = Descrips.ciddesc INNER JOIN ;
>kent!sectorline ON  Descrips.naics = Sectorline.naics INNER JOIN ;
>kent!sector ON Sectorline.cidsect = Sector.cidsect WHERE  ;
>Sector.sector = ( 'Manufacturing' )) ORDER BY company.company"
>
>
>
>Can anybody explain to me what I am doing wrong, and how I might be able to get this working as I intend?
>
>Thanks!

Andrew,
A literal string limit is 255. Add dblquotes per line and concatanate them. ie:
thisform.olecontrol1.recordsource =" SELECT company.company,company.address FROM"+ ;
" company WHERE company.cidcomp in"+;
"   (SELECT DISTINCT Company.cidcomp FROM company INNER JOIN"+;
...
You might also surround it in a text..endtext block and get rid of dblquotes. ie:
TEXT to m.lcSQL noshow textmerge
SELECT company.company,company.address FROM ;
 company WHERE company.cidcomp in ;
 (SELECT DISTINCT Company.cidcomp FROM company INNER JOIN ;
 kent!compdesc ON  Company.cidcomp = Compdesc.cidcomp INNER JOIN ;
 kent!descrips ON  Compdesc.ciddesc = Descrips.ciddesc INNER JOIN ;
 kent!sectorline ON  Descrips.naics = Sectorline.naics INNER JOIN ;
 kent!sector ON Sectorline.cidsect = Sector.cidsect WHERE  ;
 Sector.sector = ( 'Manufacturing' )) ORDER BY company.company
ENDTEXT
thisform.olecontrol1.recordsource = Chrtran(m.lcSQL,Chr(9)+';'+Chr(13)+Chr(10),Space(2))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform