ขอความช่วยเหลือแก้ไขสูตรหน่อยครับ
Posted: Sat Nov 10, 2018 10:49 am
เมื่อบันทึกข้อมูลบ้านเลขที่ ที่มีเครื่องหมาย / เมื่อไปยังหน้าแก้ไขข้อมูลแล้วเลือกบ้านเลขที่ ที่มีเครื่องหมาย / จะเกิด run-tie error 13 Type mismatch นะครับ
Code: Select all
Private Sub btnexit_Click()
Unload Rec_frm
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1.Value <> "" Then
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATA2")
Dim i As Integer
i = Application.Match(VBA.CLng(Me.ComboBox1.Value), sh.Range("B:B"), 0)
Me.TextBox2.Value = sh.Range("C" & i).Value
Set sh = ThisWorkbook.Sheets("DATA2")
i = Application.Match(VBA.CLng(Me.ComboBox1.Value), sh.Range("B:B"), 0)
Me.TextBox3.Value = sh.Range("D" & i).Value
Me.TextBox4.Value = sh.Range("E" & i).Value
Me.TextBox5.Value = sh.Range("F" & i).Value
Me.TextBox6.Value = sh.Range("G" & i).Value
Me.TextBox7.Value = sh.Range("H" & i).Value
Me.TextBox8.Value = sh.Range("I" & i).Value
Me.TextBox9.Value = sh.Range("J" & i).Value
Me.TextBox10.Value = sh.Range("K" & i).Value
Me.TextBox11.Value = sh.Range("L" & i).Value
Me.TextBox12.Value = sh.Range("M" & i).Value
Me.TextBox13.Value = sh.Range("N" & i).Value
Me.TextBox14.Value = sh.Range("O" & i).Value
Set sh = ThisWorkbook.Sheets("DATA2")
End If
End Sub
Private Sub CommandButton1_Click()
'''''''''' Check The duplicate EMP ID
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATA2")
Dim n As Long
n = Application.Match(VBA.CLng(Me.ComboBox2.Value), sh.Range("B:B"), 0)
sh.Range("B" & n).Value = Me.ComboBox2.Value
sh.Range("C" & n).Value = Me.TextBox2.Value
sh.Range("D" & n).Value = Me.TextBox3.Value
sh.Range("E" & n).Value = Me.TextBox4.Value
sh.Range("F" & n).Value = Me.TextBox5.Value
sh.Range("G" & n).Value = Me.TextBox6.Value
sh.Range("H" & n).Value = Me.TextBox7.Value
sh.Range("I" & n).Value = Me.TextBox8.Value
sh.Range("J" & n).Value = Me.TextBox9.Value
sh.Range("K" & n).Value = Me.TextBox10.Value
sh.Range("L" & n).Value = Me.TextBox11.Value
sh.Range("M" & n).Value = Me.TextBox12.Value
sh.Range("N" & n).Value = Me.TextBox13.Value
sh.Range("O" & n).Value = Me.TextBox14.Value
Me.ComboBox2.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox12.Value = ""
Me.TextBox13.Value = ""
Me.TextBox14.Value = ""
MsgBox "·Ó¡Òúѹ·Ö¡¢éÍÁÙŨӹǹ˹èÇ¡ÒÃãªé¹éÓÃÒÂà´×͹àÃÕºÃéÍÂáÅéÇ", vbInformation
End Sub
Private Sub CommandButton2_Click()
Me.ComboBox2.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox12.Value = ""
Me.TextBox13.Value = ""
Me.TextBox14.Value = ""
End Sub
Private Sub Update_Click()
Recupdate.Show
End Sub
Private Sub UserForm_Activate()
With Me.ComboBox1
End With
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATA")
Dim i As Integer
Me.ComboBox1.Clear
Me.ComboBox1.AddItem ""
For i = 4 To sh.Range("B" & Application.Rows.Count).End(xlUp).Row
Me.ComboBox1.AddItem sh.Range("B" & i).Value
Next i
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "¡´»ØèÁ ÍÍ¡ à·èÒ¹Ñ鹤ÃѺ !!!"
End If
End Sub[attachment=0]ระบบบันทึกใหม่.xlsm[/attachment]