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 : VBA code to connect to QB table with SEEK/IndexSearch Forum

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

 New Topic 
 
 Post Reply 
[1]  
 VBA code to connect to QB table with SEEK/Index 
 Author   Message 
  David 
  
 Group: Members 
 Posts: 5 
 Joined: 2007-04-12 
 Profile
 Posted : 2007-10-24 10:09:40

Hello all,

I am trying to use the seek command with a recordset based on the Customer table.  Here is the code I have so far:

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 = "SELECT * FROM Customer"
Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
 
oConnection.Open sConnectString
oRecordset.Open sSQL, oConnection, adOpenStatic, adLockOptimistic

oRecordset.Index = "PrimaryKey"

It always chokes on the last line when I try to establish the index.

So, how can I use the seek command with a QB table?

Thanks in advance :^)

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-10-24 12:45:58

You simply state what index you want QODBC to use in a ORDER BY, for example:

sSQL = "SELECT * FROM Customer Order By FullName"

 

  Top 
  David 
  
 Group: Members 
 Posts: 5 
 Joined: 2007-04-12 
 Profile
 Posted : 2007-10-24 23:54:11

Hello,

Thanks for the quick reply.  I modified my code as you suggested so that it now reads:

sSQL = "SELECT * FROM Customer ORDER BY ListID"

I still get the error message:

Current provider does not support the necesary interface for index functionality. 

Any help would be appreciated!  Thank you.

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-10-25 12:00:19
Try looking at: Can I get some examples of how to use QODBC via Visual Basic?  

  Top 
  David 
  
 Group: Members 
 Posts: 5 
 Joined: 2007-04-12 
 Profile
 Posted : 2007-11-06 06:56:08

Hello,

Can you provide some further advice please on how to use the seek command thru QODBC?  Or is there another way to optimize code that updates customers in the customers table.  I have code which establishes which customers need to have their address updated, and then loops through each one.  It is taking way too long; I have 14000 customers in my customers table.  Are there any suggestions to speed this up?

Thank you.

 

Here is a sample of my code:

Dim db As Database

Dim rso As Recordset

Dim rsrec As Recordset

Dim thispolicy As String

 

sqlitems = "Select * from QueryThatFindsUpdatedCustomers"

Set db = CurrentDb

Set rs = db.OpenRecordset(sqlitems)

thisListID = rs.Fields("ListID").Value

SQL2 = "Select * from Customer WHERE listID like '"

SQL2 = SQL2 & thisListID & "'"

Set rsrec = db.OpenRecordset(SQL2)

address2 = rs.Fields("addressfromaccess").Value

rsrec.Edit

rsrec.Fields("billaddressaddr2").Value = address2

rsrec.Update

rsrec.Close

rs.MoveNext

Loop

 

 

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-11-06 08:01:56

Replace 'like' with a = (equals) type operation. Like operations scan the whole table!

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to