Code VBA Save ทับตำแหน่งเดิม
Posted: Tue Jun 06, 2017 5:34 pm
รบกวนขอความรู้ครับ ผมสร้าง form ; edit_customer มาเพื่อค้นหาข้อมุลใน sheet ; customer_db
เมื่อเจอแล้วให้นำมาแสดงใน form ทำการแก้ไขข้อมูล และต้องการ save ข้อมูลที่แก้ทับลงไปในตำแหน่งเดิมใน sheet : customer_db
ปัญหาของผมคือ เรียกข้อมุลมาแก้ไขได้ แต่ save ไม่ได้ แก้ยังไงก็ไม่ออก ครับ
Public Sub save_mode2()
Dim save_row As Single
save_row = 8
Do Until Worksheets(db_sheet).Cells(save_row, 2).Value = CLng(edit_customer.customercode_txtbox.Value)
save_row = save_row + 1
Loop
With Worksheets(db_sheet)
.Cells(save_row, code_col).Value = edit_customer.customercode_txtbox.Value
.Cells(save_row, name_col).Value = edit_customer.customername_txtbox.Value
.Cells(save_row, address_col).Value = edit_customer.address_txtbox.Value
.Cells(save_row, id_col).Value = edit_customer.TaxID_txtbox.Value
.Cells(save_row, branch_col).Value = edit_customer.IDBranch_txtbox.Value
End With
MsgBox "ºÑ¹·Ö¡¢éÍÁÙÅÊÓàÃç¨", vbInformation, "Edit / á¡éä¢"
End Sub
เมื่อเจอแล้วให้นำมาแสดงใน form ทำการแก้ไขข้อมูล และต้องการ save ข้อมูลที่แก้ทับลงไปในตำแหน่งเดิมใน sheet : customer_db
ปัญหาของผมคือ เรียกข้อมุลมาแก้ไขได้ แต่ save ไม่ได้ แก้ยังไงก็ไม่ออก ครับ
Public Sub save_mode2()
Dim save_row As Single
save_row = 8
Do Until Worksheets(db_sheet).Cells(save_row, 2).Value = CLng(edit_customer.customercode_txtbox.Value)
save_row = save_row + 1
Loop
With Worksheets(db_sheet)
.Cells(save_row, code_col).Value = edit_customer.customercode_txtbox.Value
.Cells(save_row, name_col).Value = edit_customer.customername_txtbox.Value
.Cells(save_row, address_col).Value = edit_customer.address_txtbox.Value
.Cells(save_row, id_col).Value = edit_customer.TaxID_txtbox.Value
.Cells(save_row, branch_col).Value = edit_customer.IDBranch_txtbox.Value
End With
MsgBox "ºÑ¹·Ö¡¢éÍÁÙÅÊÓàÃç¨", vbInformation, "Edit / á¡éä¢"
End Sub