重新查询子窗体



我想通过将我的SQL代码转换为String来重新查询我的子表单,然后执行重新查询功能。问题是,我无法将下面的SQL代码转换为.RecordSource可以评估的正确字符串。

这是我的原始SQL代码:

SELECT tbl_Records.Inst_ID, [tbl_Instruments].[Type] & "-" & [tbl_Instruments].[Item] AS [Tool ID], tbl_Records.Cal_Date AS Cal_Date, tbl_Cal_By.Name_ABBR AS Cal_By, tbl_Records.As_Received, tbl_Records.Result, DateAdd("d",[tbl_Instruments]![Lead_Time],DateAdd("m",[qry_CofC]![Calibration Freq],[tbl_Records]![Cal_date])) AS Next_Due, DateDiff("d",Date(),DateAdd("d",[tbl_Instruments]![Lead_Time],DateAdd("m",[qry_CofC]![Calibration Freq],[tbl_Records]![Cal_date]))) AS Due
    FROM (tbl_Cal_By RIGHT JOIN (tbl_Instruments INNER JOIN tbl_Records ON tbl_Instruments.ID = tbl_Records.Inst_ID) ON tbl_Cal_By.ID = tbl_Records.BY) INNER JOIN qry_CofC ON tbl_Instruments.ID = qry_CofC.ID
    WHERE (((Exists (SELECT 1 FROM tbl_Records t
                     WHERE t.Inst_ID = tbl_Instruments.ID
                          AND t.Cal_date > tbl_Records.Cal_Date))=False));

这就是我重新查询的方式:

Dim SQL As String
SQL = "ABOVE ORIGINAL SQL CODE"
subform_Records.Form.RecordSource = SQL
subform_Records.Form.Requery

问题很可能是查询中的引号 (") - 尝试通过加倍来转义它们 - 所以

[tbl_Instruments]。[类型] & "-" &

等。

相关内容

  • 没有找到相关文章

最新更新