Private Sub Cmdbutton_nhap_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("DATA")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
MsgBox iRow
If Trim(Me.Textbox_ten.Value) = "" Then
Me.ten.SetFocus
MsgBox "Vui long dien so hop dong", vbInformation
Exit Sub
End If
ws.Cells(iRow, 1).Value = Me.Textbox_ten.Value
ws.Cells(iRow, 2).Value = Me.Textbox_diachi.Value
ws.Cells(iRow, 3).Value = Me.Textbox_lido.Value
ws.Cells(iRow, 4).Value = Me.Textbox_soluong.Value
Me.Textbox_ten.Value = ""
Me.Textbox_diachi.Value = ""
Me.Textbox_lido.Value = ""
Me.Textbox_soluong.Value = ""
Me.Textbox_ten.SetFocus
End Sub
Bạn đặt sai Name của các Textbox:Em đã xem qua các bài và video hướng dẫn tạo form,làm y theo thì ngon lành nhưng khi tạo theo ý mình thì nút Nhập không hoạt động,mong các anh chị hướng dẫn dùm (em mới tìm hiểu mấy cái code) xin cảm ơn nhiều!
Private Sub Cmdbutton_nhap_Click()Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("DATA")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If Trim(Me.[B]Me.Textbox_[/B]ten.Value) = "" Then
Me.ten.SetFocus
MsgBox "Vui long dien so hop dong", vbInformation
Exit Sub
End If
ws.Cells(iRow, 1).Value = [COLOR=#ff0000][B]Me.Textbox_[/B][/COLOR]ten.Value
ws.Cells(iRow, 2).Value = [B]Me.Textbox_[/B]diachi.Value
ws.Cells(iRow, 3).Value = [B]Me.Textbox_[/B]lido.Value
ws.Cells(iRow, 4).Value = Me.[B]Textbox_[/B]soluong.Value
Me.[COLOR=#ff0000][B]Textbox_[/B][/COLOR]ten.Value = ""
Me.[COLOR=#ff0000][B]Textbox_[/B][/COLOR]diachi.Value = ""
Me.[COLOR=#ff0000][B]Textbox_[/B][/COLOR]lido.Value = ""
Me.[COLOR=#ff0000][B]Textbox_[/B][/COLOR]soluong.Value = ""
Me.[COLOR=#ff0000][B]Textbox_[/B][/COLOR]ten.SetFocus
End Sub
Tất cả các điều khiển đều sai tên (Thiếu Textbox_)
Bạn đặt sai Name của các Textbox
Em đã xem qua các bài và video hướng dẫn tạo form,làm y theo thì ngon lành nhưng khi tạo theo ý mình thì nút Nhập không hoạt động,mong các anh chị hướng dẫn dùm (em mới tìm hiểu mấy cái code) xin cảm ơn nhiều!