Could someone kindly just look at the code and tell me what to change, Thank you
this is my first time doing this and I got really confused when looking at other people examples. Underneath is a screenshot of what I'm trying to create but every time I try to add the information this error pops up: "Compile error: Method or data member not found"
And this is the code I typed in:
Private Sub commandbutton_add_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_title.Value
ws.Cells(iRow, 2).Value = Me.textbox_name.Value
ws.Cells(iRow, 3).Value = Me.textbox_surname.Value
ws.Cells(iRow, 4).Value = Me.textbox_address.Value
ws.Cells(iRow, 5).Value = Me.textbox_party.Value
ws.Cells(iRow, 6).Value = Me.TextBox_number.Value
ws.Cells(iRow, 7).Value = Me.textbox_date.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_title.Value = ""
Me.textbox_name.Value = ""
Me.textbox_surname.Value = ""
Me.textbox_address.Value = ""
Me.textbox_party.Value = ""
Me.TextBox_number.Value = ""
Me.textbox_date.Value = ""
Me.textbox_title.SetFocus
End Sub
this is my first time doing this and I got really confused when looking at other people examples. Underneath is a screenshot of what I'm trying to create but every time I try to add the information this error pops up: "Compile error: Method or data member not found"
And this is the code I typed in:
Private Sub commandbutton_add_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_title.Value
ws.Cells(iRow, 2).Value = Me.textbox_name.Value
ws.Cells(iRow, 3).Value = Me.textbox_surname.Value
ws.Cells(iRow, 4).Value = Me.textbox_address.Value
ws.Cells(iRow, 5).Value = Me.textbox_party.Value
ws.Cells(iRow, 6).Value = Me.TextBox_number.Value
ws.Cells(iRow, 7).Value = Me.textbox_date.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textbox_title.Value = ""
Me.textbox_name.Value = ""
Me.textbox_surname.Value = ""
Me.textbox_address.Value = ""
Me.textbox_party.Value = ""
Me.TextBox_number.Value = ""
Me.textbox_date.Value = ""
Me.textbox_title.SetFocus
End Sub