|
2#
楼主 |
发表于 2008-3-1 20:52:24
|
只看该作者
Option Compare Database
Dim strNewRecord As String
Private Sub 更新查询_Click()
If finQueries("需删除的查询") = True Then '如果存在先删除
DoCmd.SetWarnings (False)
DoCmd.DeleteObject acQuery, "需删除的查询"
DoCmd.SetWarnings (True)
End If
strNewRecord =" select * FROM 入库表 where ID=1" '需更新的查询语句
Dim Db As DAO.Database
Dim Qy As DAO.QueryDef
Set Db = CurrentDb
Set Qy = Db.CreateQueryDef("需删除的查询", strNewRecord) '建一个同名的新查询
Set Db = Nothing
Set Qy = Nothing
End Sub
Function finQueries(查询名称 As String) As Boolean '判断查询是否存在的函数
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllQueries
If obj.Name = 查询名称 Then finQueries = True
Next obj
End Function
__________________________
自己解决了,呵呵 |
|