【问题标题】:Access VBA parameterized query: syntax error in the query clause is incompleteAccess VBA参数化查询:查询子句中的语法错误不完整
【发布时间】:2021-03-12 13:08:57
【问题描述】:
 recup = "SELECT id_categorie FROM T_Categorie WHERE T_Categorie.libelle = " & TxtCategId.Value

''retrieve the number of the category which corresponds to the depot

    Set dbcaisse = CurrentDb
    Set rsT = dbcaisse.OpenRecordset(recup, dbOpenDynaset)
    categorie = rsT!id_categorie
      
    ''registration of the deposit
 
 Set dbcaisse = CurrentDb
 Set rsT = dbcaisse.OpenRecordset("T_Mouvement", dbOpenDynaset)

当执行到达Set rsT = dbcaisse.OpenRecordset(recup) 的级别时出现此错误

谢谢你的回答

【问题讨论】:

标签: vba ms-access ms-access-2016


【解决方案1】:

不知道你的秘密值,如果存在它可能是文本,因此必须引用:

 recup = "SELECT id_categorie FROM T_Categorie WHERE T_Categorie.libelle = '" & TxtCategId.Value & "'"

【讨论】:

  • 您的解决方案有效,但请告诉我这个秘密价值的故事是什么(我同时了解到我对负责执行此操作的开发人员进行编码让我们失望,谢谢您向我解释)跨度>
  • 只是我们(我)不得不猜测你完成的 SQL 可能是什么。如果您发布它,错误消息的原因就很明显了。
  • 实际上消息的原因(错误)是我帖子的标题,但我还发现通过使用您的代码重新运行 + debug.print 我的查询参数化了评级,现在多亏了你,我会标记为已解决
【解决方案2】:

但是当我进行 debug.print 恢复时,我的请求带有我的价值,我有这个SELECT id_categorie FROM T_Categorie WHERE T_Categorie.libelle = Wester union

【讨论】:

    猜你喜欢
    • 2016-08-17
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    • 2019-07-22
    • 2015-07-21
    • 2019-10-10
    • 2014-02-25
    • 1970-01-01
    相关资源
    最近更新 更多