通过MSAccess 2003中的代码动态创建查询[VBA]
答
一个模糊的答案模糊的问题:)
strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID
Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL)
DoCmd.OpenQuery qdf.Name
答
感谢这个答案和一小段代码。如果有人需要定义中使用的变量数据类型,使用此:
Dim strsql As Variant
Dim qdf As QueryDef
+4
昏暗STRSQL作为字符串 – Fionnuala 2014-07-11 12:05:34
答
Dim strSql As String 'as already in example
Dim qdf As QueryDef 'as already in example
strSql = "SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID 'as already in example
On Error Resume Next
'Delete the query if it already exists
DoCmd.DeleteObject acQuery, "NewQuery"
Set qdf = CurrentDb.CreateQueryDef("NewQuery", strSql) 'as already in example
DoCmd.OpenQuery qdf.Name 'as already in example
'release memory
qdf.Close 'i changed qdef to qdf here and below
Set qdf = Nothing
唉我一直在努力的事情与此类似为过去三小时:(多谢 – 2008-12-24 00:01:55