在VBA中查询字符串后不使用rs.openRecordset有什么危害? 我有以下代码,我想知道这是否会导致任何问题。 由于我在strSQL4中使用strSQL3,我是否需要使用例如strSQL3打开strSQL3 rs.openrecordset?
strSQL3 = "SELECT DISTINCT SUBQUERY1.FullName, SUBQUERY1.FirstNames, SUBQUERY1.Surname, SUBQUERY1.Company, SUBQUERY1.EmailAddress,& _ & " SUBQUERY1.In_Email, iif(IsNull([SUBQUERY1].[In_Email]) AND IsNull([SUBQUERY2].[Company]),Null,'Email/Company') AS In_Company" _ & " FROM (" & strSQL1 & ") AS SUBQUERY1 LEFT JOIN (" & strSQL2 & ") AS SUBQUERY2 ON SUBQUERY1.Company = SUBQUERY2.Company"
strSQL4 = "SELECT SUBQUERY3.In_Company" _
& " FROM (" & strSQL3 & ") AS SUBQUERY3 WHERE (((SUBQUERY3.In_Company)='Email/Company'))"
Set rs4 = dbs.OpenRecordset(strSQL4)
rs4.MoveLast
rs4.MoveFirst
RsCount = rs4.RecordCount
答案 0 :(得分:0)
没问题。当您通过SQL字符串询问时,Openrecordset从数据库查询数据。如果您不需要访问sub中的strSQL3结果,则无需打开rercordset。