Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : Select statement on SP_Report resultsSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC v7 Forum

 New Topic 
 
 Post Reply 
[1]  
 Select statement on SP_Report results 
 Author   Message 
  PH 
  
 Group: Members 
 Posts: 41 
 Joined: 2007-02-02 
 Profile
 Posted : 2007-02-02 17:22:32

I am using the VBscript code in

http://www.qodbc.com/qodbcvisualbasic.htm

From VBA in Excel 2003.  Works perfectly.

I can send through a SELECT or an SP and get results in a RecordSet from which I could, for example get to the total row if that's the last row.  I can get what I want with VBA code if I must.

But, what if I want to just pass-thru one SQL statement that is like:  Select * from (Exec SP_Report show ... parameters...), ultimately so I can just get it to return a single total.  Anyway to do that in a single statement?

I read the posts about the Select * from OpenQuery(QODBC,'SP_Report ....'), but I'm not using SQL server, just VBA and the ADO code in the link above.

I also could not figure out how to use temp tables.

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-02-02 22:09:22

Just use sp_report like any other "SELECT" statement, for example, save the following example as sp_report.vbs to a file.

'*****************************************
Const adOpenStatic = 3
Const adLockOptimistic = 3
 
Dim oConnection
Dim oRecordset
Dim sMsg
Dim sConnectString
Dim sSQL
 
sConnectString = "DSN=Quickbooks Data;OLE DB Services=-2;"
sSQL = "sp_report CustomerBalanceSummary show Text, Label, Amount_1 parameters DateMacro = 'ThisMonthToDate', SummarizeColumnsBy = 'TotalOnly'"

Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
 
oConnection.Open sConnectString
oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic
sMsg = "**********************" & Chr(10)
Do While (not oRecordset.EOF)
      sMsg = sMsg & oRecordSet.Fields("Text")
      sMsg = sMsg & " "  & oRecordSet.Fields("Label")
      sMsg = sMsg & " $" & oRecordSet.Fields("Amount_1") & Chr(10)
      oRecordset.MoveNext
Loop
sMsg = sMsg & "**********************" & Chr(10)
MsgBox sMsg
 
oRecordset.Close
Set oRecordset = Nothing
oConnection.Close
Set oConnection = Nothing
'*****************************************

Double click on it using Windows Explorer and you will get your Customer Balances:

 

  Top 
  PH 
  
 Group: Members 
 Posts: 41 
 Joined: 2007-02-02 
 Profile
 Posted : 2007-02-03 03:24:11

Thank you Tom.

As I mentioned, I can get to what I want with VBA code, but I was trying to do a SELECT on the SP output. 

In your example, I'd like to return only the total.  I can get this from the last row of the recordset, but I was wondering how to do:

SELECT Amount_1 from (EXEC SP_Report <parms>) Where Label='Total' 

I want to do a lot of calls to this procedure and was looking for the fastest way to return only the total.

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-02-03 10:28:43

For the example I used above, I just do:

sp_report CustomerBalanceSummary show Label, Amount_1 parameters DateMacro = 'ThisMonthToDate', SummarizeColumnsBy = 'TotalOnly' where LABEL='TOTAL'

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to