\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > 2 Questions, 1 SQL, 1 Basic


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
Ok, first off: I\'m trying to pull my own query from an Access database. Now the query is already made, and i\'ve tried "SELECT * FROM query_name" but that doesn\'t work. Doesn\'t seem to want to let me pull from a query, which is fine. (Unless there is a way to do this. I\'d much rather do it this way.)
\r\n
\r\nAs I tried to work around it I found the SQL syntax from Access and plugged it in to my execute command like so:
\r\n
\r\n Set dbConn1 = CreateObject("ADODB.Connection"): dbConn1.Open "MRP", "", ""
\r\n Set dbrs = dbConn1.Execute("SELECT ServiceOrders.ServiceOrder, ServiceOrders.JobNo, Orders.OrderDate, Customers.ContactFirstName, Customers.ContactLastName, Orders.[Job Address], Orders.Street, ServiceOrders.Occupied, Customers.PhoneNumber " & _
\r\n "FROM Purchase Orders INNER JOIN Customers INNER JOIN Orders ON Customers.AccountNumber = Orders.[Account No] INNER JOIN ServiceOrders ON Orders.[Lighthouse Job No] = ServiceOrders.JobNo AND Orders.[Lighthouse Job No] = ServiceOrders.JobNo ON [Purchase Orders].JobNumber = Orders.[Lighthouse Job No] " & _
\r\n "WHERE ((([Purchase Orders].Closed)=0));")
\r\n
\r\nAnd that gives me an error on the inner From clause. I originally had parenthesis around the inner join parts, and that generated an error in the Inner Join statements. Here is the SQL directly from Access:
\r\n
\r\nSELECT ServiceOrders.ServiceOrder, ServiceOrders.JobNo, Orders.OrderDate, Customers.ContactFirstName, Customers.ContactLastName, Orders.[Job Address], Orders.Street, ServiceOrders.Occupied, Customers.PhoneNumber
\r\nFROM [Purchase Orders] INNER JOIN ((Customers INNER JOIN Orders ON Customers.AccountNumber = Orders.[Account No]) INNER JOIN ServiceOrders ON (Orders.[Lighthouse Job No] = ServiceOrders.JobNo) AND (Orders.[Lighthouse Job No] = ServiceOrders.JobNo)) ON [Purchase Orders].JobNumber = Orders.[Lighthouse Job No]
\r\nWHERE ((([Purchase Orders].Closed)=0));
\r\n
\r\nAny help would be GREATLY appreciated.
\r\n
\r\nAlso, I want to display and print reports from the results of these recordsets. What would be the best way to go about this? Recordsets could be as large as 1,000 records or more, but will usually hover around the 200-500 mark.
\r\n
\r\nThank you all for your time.
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[446816] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 07-28-2003, 06:49 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n KnooKie\r\n KnooKie is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 07-28-2003, 06:37 AM
Sabre056 Sabre056 is offline
Newcomer
 
Join Date: Jul 2003
Posts: 23
Default 2 Questions, 1 SQL, 1 Basic


Ok, first off: I'm trying to pull my own query from an Access database. Now the query is already made, and i've tried "SELECT * FROM query_name" but that doesn't work. Doesn't seem to want to let me pull from a query, which is fine. (Unless there is a way to do this. I'd much rather do it this way.)

As I tried to work around it I found the SQL syntax from Access and plugged it in to my execute command like so:

Set dbConn1 = CreateObject("ADODB.Connection"): dbConn1.Open "MRP", "", ""
Set dbrs = dbConn1.Execute("SELECT ServiceOrders.ServiceOrder, ServiceOrders.JobNo, Orders.OrderDate, Customers.ContactFirstName, Customers.ContactLastName, Orders.[Job Address], Orders.Street, ServiceOrders.Occupied, Customers.PhoneNumber " & _
"FROM Purchase Orders INNER JOIN Customers INNER JOIN Orders ON Customers.AccountNumber = Orders.[Account No] INNER JOIN ServiceOrders ON Orders.[Lighthouse Job No] = ServiceOrders.JobNo AND Orders.[Lighthouse Job No] = ServiceOrders.JobNo ON [Purchase Orders].JobNumber = Orders.[Lighthouse Job No] " & _
"WHERE ((([Purchase Orders].Closed)=0));")

And that gives me an error on the inner From clause. I originally had parenthesis around the inner join parts, and that generated an error in the Inner Join statements. Here is the SQL directly from Access:

SELECT ServiceOrders.ServiceOrder, ServiceOrders.JobNo, Orders.OrderDate, Customers.ContactFirstName, Customers.ContactLastName, Orders.[Job Address], Orders.Street, ServiceOrders.Occupied, Customers.PhoneNumber
FROM [Purchase Orders] INNER JOIN ((Customers INNER JOIN Orders ON Customers.AccountNumber = Orders.[Account No]) INNER JOIN ServiceOrders ON (Orders.[Lighthouse Job No] = ServiceOrders.JobNo) AND (Orders.[Lighthouse Job No] = ServiceOrders.JobNo)) ON [Purchase Orders].JobNumber = Orders.[Lighthouse Job No]
WHERE ((([Purchase Orders].Closed)=0));

Any help would be GREATLY appreciated.

Also, I want to display and print reports from the results of these recordsets. What would be the best way to go about this? Recordsets could be as large as 1,000 records or more, but will usually hover around the 200-500 mark.

Thank you all for your time.
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL error in Vb Code blong824 Database and Reporting 16 03-14-2004 05:07 PM
Problem with writing Twice Renidrag Web Programming 20 11-07-2002 02:52 PM
from Access 2 SQL ~ Basic questions AnakinVB Database and Reporting 7 09-22-2002 09:08 PM
Creating Access Databases TomGuy Database and Reporting 8 07-10-2002 10:56 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->