Create a query dynamically through code in MSAccess 2003 [VBA]
问题 Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this? 回答1: A vague answer for a vague question :) strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL) DoCmd.OpenQuery qdf.Name 回答2: Thanks for this answer and the small piece of code. If somebody needs to define the datatypes for the variables used, use this: Dim strsql As Variant Dim qdf As QueryDef 回答3: Dim strSql As String 'as already in