|
本帖最后由 todaynew 于 2011-6-27 14:54 编辑
fxbianxiu 发表于 2011-6-27 13:48
嘿嘿,谢谢啦,
还有一个问题,我想在窗口的查询中建立一个带参数的查询,在代码中如何能自动加上参数 ...
把上面的代码改一下就完事了嘛:
1、修改查询:
Function UpSql(sqlname as string,ssql as string)
'功能:修改SQL语句
'示例:call UpSql("名单查询","select * from 部门ID=" & me.部门ID.value)
Dim Qdef As QueryDef
Set Qdef = CurrentDb.QueryDefs(sqlname)
Qdef.SQL=ssql
Qdef.Close
Set Qdef = Nothing
End Function
2、创建查询:
Function CrtSQL(strname As String, ssql As String)
'功能:创建SQL语句
'示例:call CrtSql("名单查询","select * from 部门ID=" & me.部门ID.value)
Dim Qdef As QueryDef
Set Qdef = CurrentDb.CreateQueryDef(strname)
Qdef.SQL = ssql
Qdef.Close
Set Qdef = Nothing
End Function
|
|