Hi các bạn,
Vui lòng sửa giúp đọan code sql bị sai sau sự kiện afterupdate :
Mong nhận reply từ các bạn từ dòng báo lỗi màu đỏ trên.
Thanks,
BìnhTam
Vui lòng sửa giúp đọan code sql bị sai sau sự kiện afterupdate :
PHP:
Private Sub cbocol_BeforeUpdate(Cancel As Integer)
Dim strNewData As String
Dim I As Integer
If IsNull(Me.cbocol.Value) Then Exit Sub
strNewData = Me.cbocol.Value
txtcol.text= "#" & Left(strNewData, 3)
For I = 0 To Me.cbocol.ListCount - 1
If Me.cbocol.ItemData(I) = strNewData Then Exit Sub
Next I
Dim intAnswer As Integer
intAnswer = MsgBox("Color" & Chr(34) & strNewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNoCancel, "LIST OF Color")
Dim strSQL As String
Select Case intAnswer
Case vbYes
' Allow entry and add new item to the list
strSQL = "INSERT INTO col([color],[code]) " & _
"VALUES (" & CStr(strNewData) & "," & CStr(txtcol) & ");"
DoCmd.SetWarnings False
[COLOR=red]DoCmd.RunSQL strSQL '== bị báo lỗi tại dòng này
[/COLOR]
DoCmd.SetWarnings True
blnNewListItem = True
MsgBox "The new Color has been added to the list." _
, vbInformation, "List of Color(s)"
Case vbNo
' Allow entry but do not add item to list
' No action necessary
Case vbCancel
' Do not allow entry
MsgBox "Please choose a Color from the list.", _
vbExclamation, "List of Color"
Me.cbocol.Undo
Me.cbocol.Dropdown
Cancel = True
End Select
End Sub
Thanks,
BìnhTam
Chỉnh sửa lần cuối bởi điều hành viên: