johnnyg123
asked on
Make Table Query in Access 2003 VBA
I am executing a make table paramater query in vba
using the following code
Dim db As Database
Dim qry As QueryDef
'use current database
Set db = CurrentDb()
'execute query
Set qry = db.QueryDefs("Create_Daily StoreSales FromROW")
'specify value of parameters
qry.Parameters("StartDate" ) = strStartDate
qry.Parameters("EndDate") = strEndDate
qry.Execute
When an attempt is made to try and execute qry.execute
it says the table already exists
I there a way to force the make table query delete the table like it does when you double click on it in the query window?
using the following code
Dim db As Database
Dim qry As QueryDef
'use current database
Set db = CurrentDb()
'execute query
Set qry = db.QueryDefs("Create_Daily
'specify value of parameters
qry.Parameters("StartDate"
qry.Parameters("EndDate") = strEndDate
qry.Execute
When an attempt is made to try and execute qry.execute
it says the table already exists
I there a way to force the make table query delete the table like it does when you double click on it in the query window?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try unchecking the Action queries box under Tools - Options Edit/Find
Other than that you could just delete the table first - then create it - With an on_error that basically ignores the error
Other than that you could just delete the table first - then create it - With an on_error that basically ignores the error
Dim db As Database
Dim qry As QueryDef
'use current database
Set db = CurrentDb()
if dcount("*","msysobjects","
db.execute "drop table nameoftable"
end if
'execute query
Set qry = db.QueryDefs("Create_Daily
'specify value of parameters
qry.Parameters("StartDate"
qry.Parameters("EndDate") = strEndDate
qry.Execute