gpt4 book ai didi

date - Access 2010 VBA语法错误 '3075'

转载 作者:行者123 更新时间:2023-12-03 08:28:17 25 4
gpt4 key购买 nike

我不确定是否遗漏了什么,我正在尝试查找语法错误的位置,但我根本无法,可能是因为我花了2个小时来尝试查找错误,所以我的眼睛在流血。

表格代码:

Option Compare Database

Private Sub btnZatwierdzAccessories_Click()

Dim strSQLdeleteAccessories As String

Dim strSQLzm1accessoriesA As String
Dim strSQLzm1accessoriesB As String
Dim strSQLzm1accessoriesC As String
Dim strSQLzm1accessoriesD As String

Dim strSQLzm2accessoriesA As String
Dim strSQLzm2accessoriesB As String
Dim strSQLzm2accessoriesC As String
Dim strSQLzm2accessoriesD As String

Dim strSQLzm3accessoriesA As String
Dim strSQLzm3accessoriesB As String
Dim strSQLzm3accessoriesC As String
Dim strSQLzm3accessoriesD As String

strSQLdeleteAccessories = "DELETE * FROM [dbGrafikAccessories] WHERE dataAccessories = #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#;"

strSQLzm1accessoriesA = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM1accessoriesA.Column(0) & "', '" & Me!listZM1accessoriesA.Column(1) & "', 'zm1', 'automatyk', 'accessories', '06001400', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm1accessoriesB = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM1accessoriesB.Column(0) & "', '" & Me!listZM1accessoriesB.Column(1) & "', 'zm1', 'piankowanie', 'accessories', '06001400', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm1accessoriesC = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM1accessoriesC.Column(0) & "', '" & Me!listZM1accessoriesC.Column(1) & "', 'zm1', 'szycie', 'accessories', '06001400', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm1accessoriesD = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM1accessoriesD.Column(0) & "', '" & Me!listZM1accessoriesD.Column(1) & "', 'zm1', 'dodatkowy', 'accessories', '06001400', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"

strSQLzm2accessoriesA = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM2accessoriesA.Column(0) & "', '" & Me!listZM2accessoriesA.Column(1) & "', 'zm2', 'automatyk', 'accessories', '14002200', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm2accessoriesB = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM2accessoriesB.Column(0) & "', '" & Me!listZM2accessoriesB.Column(1) & "', 'zm2', 'piankowanie', 'accessories', '14002200', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm2accessoriesC = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM2accessoriesC.Column(0) & "', '" & Me!listZM2accessoriesC.Column(1) & "', 'zm2', 'szycie', 'accessories', '14002200', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm2accessoriesD = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM2accessoriesD.Column(0) & "', '" & Me!listZM2accessoriesD.Column(1) & "', 'zm2', 'dodatkowy', 'accessories', '14002200', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"

strSQLzm3accessoriesA = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM3accessoriesA.Column(0) & "', '" & Me!listZM3accessoriesA.Column(1) & "', 'zm3', 'automatyk', 'accessories', '22000600', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm3accessoriesB = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM3accessoriesB.Column(0) & "', '" & Me!listZM3accessoriesB.Column(1) & "', 'zm3', 'piankowanie', 'accessories', '22000600', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm3accessoriesC = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM3accessoriesC.Column(0) & "', '" & Me!listZM3accessoriesC.Column(1) & "', 'zm3', 'szycie', 'accessories', '22000600', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"
strSQLzm3accessoriesD = "INSERT INTO dbGrafikAccessories (imieNazwisko, numerTelefonu, zmiana, praca, zaklad, godzina, dataAccessories, dataAccessoriesDo) VALUES ('" & Me!listZM3accessoriesD.Column(0) & "', '" & Me!listZM3accessoriesD.Column(1) & "', 'zm3', 'dodatkowy', 'accessories', '22000600', #" & Format(Me!txtDataAccessories, "d-m-yyyy") & "#, #" & Format(Me!txtDataAccessoriesDo, "d-m-yyyy") & "#);"

DoCmd.SetWarnings False

DoCmd.RunSQL strSQLdeleteAccessories

DoCmd.RunSQL strSQLzm1accessoriesA
DoCmd.RunSQL strSQLzm1accessoriesB
DoCmd.RunSQL strSQLzm1accessoriesC
DoCmd.RunSQL strSQLzm1accessoriesD

DoCmd.RunSQL strSQLzm2accessoriesA
DoCmd.RunSQL strSQLzm2accessoriesB
DoCmd.RunSQL strSQLzm2accessoriesC
DoCmd.RunSQL strSQLzm2accessoriesD

DoCmd.RunSQL strSQLzm3accessoriesA
DoCmd.RunSQL strSQLzm3accessoriesB
DoCmd.RunSQL strSQLzm3accessoriesC
DoCmd.RunSQL strSQLzm3accessoriesD

DoCmd.SetWarnings True

End Sub

调试将我重定向到该行:
    DoCmd.RunSQL strSQLzm1accessoriesA

带有错误信息:
Run-time error '3075':
Syntax error in date in query expression '#'.

最佳答案

首先,您的日期格式应为:

.. #" & Format(Me!txtDataAccessories, "yyyy\/mm\/dd") & "#, 

其次,如果文本框为空,则SQL将失败。

因此,请写出创建的SQL进行调试:
Debug.Print strSQLzm1accessoriesA

然后研究输出。

关于date - Access 2010 VBA语法错误 '3075',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36501943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com