gpt4 book ai didi

sql - 'Incdntno.Value' 处的 undefined variable

转载 作者:行者123 更新时间:2023-12-02 10:42:15 27 4
gpt4 key购买 nike

我无法编译它,它在“Incdntno.Value”处编译期间不断给出 undefined variable 错误。我尝试将 Incdntno 调暗为 Integer,但随后获得了 Invalid qualifier。我有一个类似的代码(见第二个代码块)。我不需要很多工作代码部分的内容,所以我删除了它。如果有人能指出我在第一个代码块中哪里出错了,我将不胜感激?非常感谢你

Private Sub Incdntno_AfterUpdate()
Dim conn As ADODB.Connection
Dim sSQL As String



Set conn = CurrentProject.Connection


If IsNull([Incdntno]) Then
Me.Dirty = False
End If
Dim Incident As String
Incident = Incdntno.Value
sSQL = "INSERT INTO tblFieldIncident_Complaint_InspHist ( Incdntno, InspectID, Dt_Inspect ) SELECT " & [Incdntno] & ", " & [InspectID] & ", " & [InspDate] & " FROM tblInspect WHERE Incdntno='" & Incident & "';"
conn.Execute sSQL
'Me.Requery
frmInspectItemsSub.Requery

ProcExit:
Exit Sub

End Sub

有效的代码:
Private Sub InspectType_AfterUpdate()
Dim conn As ADODB.Connection
Dim sSQL As String
Dim wYesNo As Integer
On Error GoTo ProcErr

If Not mbNewRecord Then
wYesNo = MsgBox("Changing the inspection type will erase the current entries and insert items specific to the new inspection. Proceed?", vbYesNo, "Inspection item update")
If wYesNo <> vbYes Then GoTo ProcExit
End If

Set conn = CurrentProject.Connection
If Not mbNewRecord Then
conn.Execute "DELETE FROM tblInspectItems WHERE InspectID=" & InspectID
End If

If IsNull([InspectID]) Then
Me.Dirty = False
End If
Dim inspType As String
inspType = InspectType.Value
sSQL = "INSERT INTO tblInspectItems ( ItemID, InspectID ) SELECT ItemID, " & [InspectID] & " FROM tblRefInspectItemCodes WHERE InspectType='" & inspType & "';"
conn.Execute sSQL
'Me.Requery
frmInspectItemsSub.Requery

ProcExit:
Exit Sub

ProcErr:
ErrMsg ("frmInspect.InspectType_AfterUpdate")
Resume ProcExit
End Sub

最佳答案

这听起来像是如果您复制事件代码会发生什么。仔细查看您的控件名称并确保它们匹配。此外,您需要确保 [Event Procedure] 出现在事件属性中。如果您更改控件名称,该链接可能不会自动出现。

关于sql - 'Incdntno.Value' 处的 undefined variable ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22075109/

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