Advertisement

06.26.2007 at 01:47AM PDT, ID: 22657701
[x]
Attachment Details

Query finds records in Access interface, but not in VB6 or VBA.

Asked by GrahamSkan in Access Coding/Macros, Microsoft Access Database, Visual Basic Programming

Tags: access, query, vba

I have one particular query that works OK in Access from the design interface, returning 13 records, but returns no records when run from code. Other queries work. It isn't particularly complex.

This is the stored query

SELECT Volume.label, Path.name, Thumbnail.name
FROM Volume INNER JOIN (Path INNER JOIN Thumbnail ON Path.idPath = Thumbnail.idPath) ON Volume.idVol = Path.idVol
WHERE (((Volume.label)='sata_p1') AND ((Path.name)='My Pictures\Photos\2003\2003_0524') AND ((Thumbnail.name) Like '2003*'))
ORDER BY Thumbnail.name;


This is the VB code

Sub TestSQL()
    Dim cnThumb As ADODB.Connection
    Dim rsDateName As New ADODB.Recordset
   
    Set cnThumb = CurrentProject.Connection
    rsDateName.Open "qryTest", cnThumb, adOpenDynamic, adLockPessimistic, adCmdStoredProc
   
    If Not rsDateName.EOF Then
        rsDateName.MoveLast
        Debug.Print rsDateName.RecordCount
    End If
   
End Sub

Access 2003, SP2; Windows 2000 SP4; ADO 2.7 library.Start Free Trial
[+][-]06.26.2007 at 01:54AM PDT, ID: 19361801

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Access Database, Visual Basic Programming
Tags: access, query, vba
Sign Up Now!
Solution Provided By: TimCottee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.26.2007 at 03:59AM PDT, ID: 19362450

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.26.2007 at 04:04AM PDT, ID: 19362477

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2007 at 04:27AM PDT, ID: 19362595

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.26.2007 at 06:26AM PDT, ID: 19363386

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2007 at 08:31AM PDT, ID: 19364729

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32