我无法使用SQL字符串重新查询子表单,这是我的代码:
Dim Day As Integer
Day = txt_Days.Value
SQL = "SELECT [qry_Records].[Tool_ID], [qry_Records].[Cal_Date]," _
& "[qry_Records].[Cal_By], [qry_Records].[As_Received], " _
& "[qry_Records].[Result], [qry_Records].[Next_Due], " _
& "[qry_Records].[Due] FROM [qry_Records]" _
& " WHERE [qry_Records].[Due] < Day;"
subform_View_Search_Records.Form.RecordSource = SQL
我尝试使用不同的变体来引用SQL字符串末尾的Day变量,例如下面但没有任何作用:
& " WHERE [qry_Records].[Due] < ""Day"";"
& " WHERE [qry_Records].[Due] < '"Day"';"
非常感谢您的帮助!
答案 0 :(得分:0)
你只需添加几个&符号
& " WHERE [qry_Records].[Due] < " & Day & ";"
答案 1 :(得分:0)
我会试试这个:
SQL = "SELECT [Tool_ID], [Cal_Date]," _
& "[Cal_By], [As_Received], " _
& "[Result], [Next_Due], " _
& "[Due] FROM [qry_Records]" _
& " WHERE [Due] < " & format$(txtDays, "\#dd\/mm\/yyyy\#")
subform_View_Search_Records.Form.RecordSource = SQL
最后的“;”是没用的。