ไฟล์แนบครับ
code Sub cmdAdd_Click อยู่ในฟอร์ม frmReturntool ปุ่ม add ครับ
code ที่ผิด
Code: Select all
Private Sub cmdAdd_Click()
If ComboBox1 = "" Then
MsgBox "ท่านต้อง อ้างอิงจากการ ค้นหาเลขที่ใบยืม ใน Box ด้านซ้ายก่อน", vbOKOnly + vbInformation, "เพื่มข้อมูลในใบคืนเครื่องมือ"
Exit Sub
End If
If ListBox1.ListIndex = -1 Then
MsgBox "ท่านต้อง้เลือกรายการใน List box ด้านล่างก่อน", vbOKOnly + vbInformation, "เพื่มข้อมูลในใบคืนเครื่องมือ"
Exit Sub
End If
' Dim iRow As Long
' iRow = [Counta(Addrequisition1!F:F)] + 1
' Sheets("Addrequisition1").Select
' If iRow = Me.TextBox1.Value Then
' MsgBox "Add ค่าซ้ำกัน", vbOKOnly + vbInformation, "เพื่มข้อมูลในใบคืนเครื่องมือ"
' Exit Sub
' End If
' Dim lng As Long, i As Integer
' Sheets("Addrequisition1").Select
' Range("F1").Select
' lng = Sheets("Addrequisition1").Range("F" & Rows.Count) _
' .End(xlUp).Row
' Do While ActiveCell.Row <= lng
' If ActiveCell.Value <> TextBox1.Text Then
' i = i + 1
' End If
' ActiveCell.Offset(1, 0).Select
' Loop
' If i = 0 Then
' MsgBox "Not found"
' End If
Dim lng As Long
Sheets("Addrequisition1").Select
Range("F1").Select
lng = Sheets("Addrequisition1").Range("F" & Rows.Count) _
.End(xlUp).Row
Do While ActiveCell.Row <= lng
If ActiveCell.Value = TextBox1.Text Then
MsgBox "ข้อความซ้ำ"
Exit Sub
End If
ActiveCell.Offset(1, 0).Select
Loop
Call SubmitfrmReturntool
Call ResetReturntool3
Me.ListBox2.ListIndex = -1 'ไม่โชว์แถบสีน้ำเงิน
MsgBox "ส่งข้อมูลไปยังเอกสารใบเบิกยืม/ตืน เครื่องมือแล้ว", vbOKOnly + vbInformation, "Confirmation"
End Sub
ชุดด้านล่างนี้เป็น code ที่ใช้ตรวจสอบครับ
Dim lng As Long
Sheets("Addrequisition1").Select
Range("F1").Select
lng = Sheets("Addrequisition1").Range("F" & Rows.Count) _
.End(xlUp).Row
Do While ActiveCell.Row <= lng
If ActiveCell.Value = TextBox1.Text Then
MsgBox "ข้อความซ้ำ"
Exit Sub
End If
ActiveCell.Offset(1, 0).Select
Loop
You do not have the required permissions to view the files attached to this post.