ขอความช่วยเหลือ ครับ 2 ชั่วโมงแล้วที่หาสาเหตุไม่ได้ คื เมื่อกดปุ่ม add ใน form เพื่อบันทึกข้อมูลลง database มันขึ้นว่า Syntax Error และยังไม่สามารถบันทึกข้อมูลได้ และ ผมอยากปรับความยาวของ combo box ที่ชื่อว่า cbotrainer ให้มันสั้นลง ผมไม่รู้ว่าต้องปรับที่ตรงใหน
Option Explicit
Private Sub cboHowToEval_Change()
End Sub
Private Sub cboOperation1_Change()
End Sub
Private Sub cboOperation2_Change()
End Sub
Private Sub cboOperation3_Change()
End Sub
Private Sub cboProduct_Change()
End Sub
Private Sub cboTrainer_Change()
End Sub
Private Sub txtClassTitle_Change()
End Sub
Private Sub txtCourseID_Change()
End Sub
Private Sub txtDay_Change()
End Sub
Private Sub txtFull_Change()
End Sub
Private Sub txtHour_Change()
End Sub
Private Sub txtSubClass_Change()
End Sub
Private Sub txtSubClassTitle_Change()
End Sub
Private Sub cmdAdd_Click()
Dim 1Row As Long
Dim 1Trainer As Long
Dim ws As Worksheet
Set ws = Worksheets("CourseData")
'find first empty row in database
lRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a employee number
If Trim(Me.cboTrainer.Value) = "" Then
Me.cboTrainer.SetFocus
MsgBox "Please enter a employee number"
Exit Sub
End If
'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.cboTrainer.Value
.Cells(lRow, 2).Value = Me.cboTrainer.List(lTrainer, 1)
.Cells(lRow, 3).Value = Me.txtCourseID.Value
.Cells(lRow, 4).Value = Me.txtClassTitle.Value
.Cells(lRow, 5).Value = Me.txtSubClass.Value
.Cells(lRow, 6).Value = Me.txtSubClassTitle.Value
.Cells(lRow, 7).Value = Me.cboHowToEval.Value
.Cells(lRow, 8).Value = Me.txtFull.Value
.Cells(lRow, 9).Value = Me.txtDay.Value
.Cells(lRow, 10).Value = Me.txtHour.Value
.Cells(lRow, 11).Value = Me.cboProduct.Value
.Cells(lRow, 12).Value = Me.cboOperation1.Value
.Cells(lRow, 13).Value = Me.cboOperation2.Value
.Cells(lRow, 14).Value = Me.cboOperation3.Value
End With
'clear the data
Me.txtCourseID.Value = ""
Me.txtClassTitle.Value = ""
Me.txtSubClass.Value = ""
Me.txtSubClassTitle.Value = ""
Me.cboHowToEval.Value = "Select"
Me.txtFull.Value = ""
Me.txtDay.Value = ""
Me.txtHour.Value = ""
Me.cboProduct.Value = "Select"
Me.cboOperation1.Value = "Select"
Me.cboOperation2.Value = "Select"
Me.cboOperation3.Value = "Select"
Me.cboTrainer.Value = "Select"
Me.cboTrainer.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim cHowToEval As Range
Dim cProduct As Range
Dim cOperation As Range
Dim cTrainer As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")
Me.txtCourseID.Value = ""
Me.txtClassTitle.Value = ""
Me.txtSubClass.Value = ""
Me.txtSubClassTitle.Value = ""
Me.cboHowToEval.Value = "Select"
Me.txtFull.Value = ""
Me.txtDay.Value = ""
Me.txtHour.Value = ""
Me.cboProduct.Value = "Select"
Me.cboOperation1.Value = "Select"
Me.cboOperation2.Value = "Select"
Me.cboOperation3.Value = "Select"
Me.cboTrainer.Value = "Select"
Me.cboTrainer.SetFocus
End Sub
You do not have the required permissions to view the files attached to this post.