Solved

Max Length of ADO Recordset Source property

Posted on 2004-08-18
6
2,208 Views
Last Modified: 2008-01-09
Does anyone know if there is a maximum length of the source property of an ado recordset.

If there is, what is the maximum length, and does anyone have a way of working around this.

I have a search form in which the user can enter criteria into a lot (40+) fields. Needless to say, the SQL query text can become quite long, and I seem to be having a problem if the query string is too long, am getting an error

"7874 : Microsoft Access can't find the object 'Recordset.'"

Thanks in advance for any assistance!
0
Comment
Question by:geefx
  • 3
  • 2
6 Comments
 
LVL 84
ID: 11839929
I don't know that this is your problem; I've seen some VERY long SQL String for ADO Recordsets. FWIW, i couldn't find any documnetation that explicitly spelled out the number of characters the ADO .Source property could have.

Could you post the portion of the code where you're setting/resetting and filling your recordset?
0
 
LVL 34

Expert Comment

by:flavo
ID: 11840058
Id say its the same as a query def (gueesing here) but that would be about 64k chars.

Are you sure that's the problem... does it work with a simple Select * from tblMyTable.... ???

Dave
0
 

Author Comment

by:geefx
ID: 11848159
Hmmm...not sure that is the problem at all, but seemed to be the only thing that it could be from my experimentation - if I shortened the sql string it seemed to work - it definitely wasn't an error in the sql string.

code portion:

  Dim rsx As ADODB.Recordset
    Set rsx = New ADODB.Recordset
    With rsx
        .ActiveConnection = CurrentProject.Connection
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        strSQLz = "LONG SQL STRING HERE"
        .Source = strSQLz
        .Open
        Set Me.sfmSearchAllResults.Form.Recordset = rsx
        .ActiveConnection = Nothing
    End With

The error occurs (with a long sql string only) with the statement
        Set Me.sfmSearchAllResults.Form.Recordset = rsx
The recordset is actually returned fine (so I guess that it is not the length of the ado .source property), but when I assign the recordset to the subform, that is when it fails.

It works fine if I use a "select * from products" type string.

Very Very strange!!!
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 11848393
Hmmm ... the max length of a .Recordsource is 2048 characters, I believe, and I'm pretty sure the Max Length of an ADO Recordset's .Source property is the same ... have you tried setting a breakpoint, copying the SQL being used to open the Recordset and pasting that into a query to make sure there are no troubles with it?

Here's a good MSDN article on binding forms to Recordsets:
http://support.microsoft.com/default.aspx?scid=kb;en-us;281998
0
 

Author Comment

by:geefx
ID: 11866266
the limit on the length of the sql string does appear to be 2048 chars as you say LSMConsulting - did a bit of playing around, and found it was fine for 2048, failed for 2049 characters in the sql string.

So based on that here is what I think is happening:
The ado recordset is returned with no problems, so there doesn't seem to be a limit on the size of the sql string here (at least not that I've hit)
When the recordset is assigned to the form, the source of the ADO recordset is assigned to the source of the form. So if this is > 2048 characters, then it fails, just as it would have if I had assigned the sql statement as the recordsource of the form itself.

Pretty annoying - don't know if there is a workaround for this??

LSMConsulting, have accepted your answer since you pointed me in the right direction.

Thanks for your help on this - very much appreciated - if you have any ideas on how to work around this, I'd love to hear them!
0
 
LVL 84
ID: 11868927
Two things come to mind:

1) Trim your sql as much as possible - for example, remove table names where possible:

SELECT tblCust.FName, tblCust.LName FROM tblCust

Instead, write this:
SELECT FName, LName FROM tblCust

2) Try writing your results to a temporary table, then you can do a SELECT * FROM YourTempTable" to populate your form/contro.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

912 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

19 Experts available now in Live!

Get 1:1 Help Now