Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Code using ADO Returning Too Many Records

Status
Not open for further replies.

RealQuiet

Programmer
Feb 11, 2001
54
US
I am using Access 2000 and have a stored query which is a union of three other queries. When I just run the query, it gives me the results I expect. However, in a code module using ADO, it is returning more records than just running the query manually. If I change the code to use a DAO recordset, the results are again correct. Has anyone run into this problem of ADO returning different result than DAO opening the same stored query?
 
RealQuiet,
take the query you've created and turn it into a stored procedure, then use ADO to call the stored procedure... That should work
 
loveTech,
I'm not really sure what you mean. As far as I know, a saved query in Access is the equivalent to a stored procedure in SQL Server, etc. Let me know if this is not the case. If so, the query is saved in Access, but returns a different result set depending on whether I run it using DAO or ADO.
 
You are not providing enough information for anybody to help you. Please provide the sql string and the vba code for both calls.
 
The reason for my post was to see if anyone had run into a similar situation as what I described. The calls to retrieve the data are very simple.
DAO:
Set rstransactions = CurrentDb.OpenRecordset("ShoppersCharge-All")

ADO:
Set rstransactions = New ADODB.Recordset
rstransactions.Open "ShoppersCharge-All", CurrentProject.Connection, adOpenStatic, adLockOptimistic, adCmdStoredProc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top