How to combine those two subs?
first check if qurey Q1 already exsits, if it does not, create it, otherwise create it.
THX
Jeff
first check if qurey Q1 already exsits, if it does not, create it, otherwise create it.
THX
Jeff
Code:
Public Sub MakeQuery1()
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim sqlText As String
Set db = Access.CurrentDb
sqltxt = "Select * from sales_channel"
Set qry = db.CreateQueryDef("Q1", sqltxt)
qry.Close
Set qry = Nothing
Set db = Nothing
End Sub
Public Sub ModifyQuery1()
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim sqltxt As String
Set db = Access.CurrentDb
sqltxt = "Select * from sales_channel"
Set qry = db.QueryDefs("Q1")
qry.Sql = sqltxt
Set qry = Nothing
Set db = Nothing
End Sub