我正在创建一个用户窗体以更新学生出勤详细信息。通过Excel用户窗体更新MS Access中的表时,数据未更新。而是在attendanceStatus列中显示0或-1,在Excuse列this is a picture of my ClassDate table after attempting to update for student IT01 and IT02中不显示任何内容。
我的用户窗体包含courseCode、subject、classDate、studentID、name、attendance status和excuse的值。因此,我将使用classDate、courseCode和studentID的值来查找要更新的学生的出勤情况。这是我尝试使用“用户窗体更新”按钮来更新MS Access ClassDate表中的attendanceStatus和Excuse列。
Private Sub CommandButton1_Click()
Dim cnt As ADODB.Connection
Dim db_path As String
Dim db_str As String
db_path = "C:\Users\Lenovo\Documents\BIT\SEM4\SAD\StudentAttendanceMonitoring\attendance1.accdb;"
Set cnt = New ADODB.Connection
db_str = "provider=Microsoft.ACE.OLEDB.12.0; data source=" & db_path
cnt.Open (db_str)
insert_str = "update Classdate set attendanceStatus = '" & cmbUpdateStatus.Value & "' and Excuse = '" & txtUpdateExcuse.Value & "' where classDate = '" & cmbUpdateDate.Value & "' and courseCode = '" & cmbUpdateCourseCode.Value & "' and studentID = '" & cmbUpdateStudentID.Value & "'"
Debug.Print insert_str
cnt.Execute (insert_str)
MsgBox "Updated sucessfully", vbInformation
Set cnt = Nothing
End Sub
1条答案
按热度按时间7lrncoxx1#
应该用逗号分隔字段更新表达式,而不是
and
。