Access Queries not running properly in VB6

EddiRae

Registered User.
Local time
Today, 07:05
Joined
Aug 4, 2007
Messages
53
I am adding queries that I created in Access to run in an application.
I have given you the meat of the subroutine.
The tabledefs.delete is working. It is the rest of the process that is not working.

The queries are not displaying any data when I know there is data. If I run in Access, I get data.

If you could let me know what I have wrong, I would greatly appreciate it.

The code is below.

Code:
Dim db As Database
    Dim ws As Workspace
    Dim qry As QueryDef
 
 
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(sStatsPath)
 
    For i = 0 To imt
        db.TableDefs.Delete ("Stp01-DailyDetail")
        db.TableDefs.Delete ("Stp02-ReschedEst")
        db.TableDefs.Delete ("Stp03-Manhours")
 
        'Remove data for date
        Set qry = db.QueryDefs("DELETE")
        qry.Parameters("calc_date") = calcdate
        qry.Execute
        qry.Close
 
        Set qry = db.QueryDefs("ACCESS_Raw Data - D")
        qry.Parameters("calc_date") = calcdate
        qry.Execute
        qry.Close
 
        Set qry = db.QueryDefs("ACCESS_Res-Est-S")
        qry.Parameters("calc_date") = calcdate
        qry.Execute
        qry.Close
 
        Set qry = db.QueryDefs("ACCESS_Manhour-S")
        qry.Parameters("calc_date") = calcdate
        qry.Execute
        qry.Close
 
        Set qry = db.QueryDefs("Answers-S")
        qry.Parameters("calc_date") = calcdate
        qry.Execute
        qry.Close
 
        calcdate = DateAdd("d", 1, calcdate)
    Next i

Thanks in advance!!
Eddi Rae
:confused:
 
Last edited:
I found it!!! It was so simple that I didn't see it. Since I have spaces in the query name, you have to place brackets around the query name!!!

This statement ... Code:
Set qry = db.QueryDefs("ACCESS_Raw Data - D")​


Should be ... Code:
Set qry = db.QueryDefs("[ACCESS_Raw Data - D]")​


Thanks for all the help!!!
Eddi Rae
 

Users who are viewing this thread

Back
Top Bottom