因为我要在程序中删除查询后新建此查询,可老是提示此查询不存在,请问如何判断某查询是否存在?谢谢
Dim Conn As New ADODB.Connection
Set Conn = CurrentProject.Connection
Conn.Execute "drop table currentQuery"
Set Conn = Nothing
'**************
Dim dbs As Database, qdf As QueryDef, strSQL As String, dmonth As String
dmonth = Year(Now()) & month(Now())
Set dbs = CurrentDb
'************** judge month and create new Query
Select Case dmonth
Case 20064
MsgBox "20064"
strSQL = "SELECT JobName.[Job No], StaffName.[Staff Name], Jobschedule.[2006-4], Jobschedule.[2006-5], Jobschedule.[2006-6], Jobschedule.[2006-7], Jobschedule.[2006-8], Jobschedule.[2006-9], Jobschedule.[2006-10], Jobschedule.[2006-11], Jobschedule.[2006-12], Jobschedule.[2007-1], Jobschedule.[2007-2], Jobschedule.[2007-3], Jobschedule.[2007-4] FROM StaffName INNER JOIN (JobName INNER JOIN Jobschedule ON JobName.[Job No] = Jobschedule.[Job No]) ON StaffName.[Staff Name] = Jobschedule.[Stuff Name];"
Set qdf = dbs.CreateQueryDef("currentQuery", strSQL)
[此贴子已经被作者于2006-4-13 15:29:09编辑过]
|