G
Guest
Hi,
I've got a user form through which I am accepting various inputs & when I
click on the 'add record' button the data gets copied onto rows everytime. Is
there anything that i can do to automatically ensure the rows (after
updating) gets protected ?
I cant protect the sheet directly in this case, cos the user feeds thru the
form will not get copied to the database table then.
This is how my code currently looks.
*****************************
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data_Dump")
'Find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
' Check for incomplete entries before 'Adding Recod'
If Trim(Me.CboStaffName.Value) = "" Then
Me.CboStaffName.SetFocus
MsgBox "Please enter Staff Name"
Exit Sub
End If
' To Copy the data to the database
ws.Cells(iRow, 1).Value = Me.Txtdate.Value
ws.Cells(iRow, 2).Value = Me.Txttime.Value
' Clear the data
Me.Txtdate.Value = Format(Date, "dd-mmm-yy")
Me.Txttime.Value = Format(Time, "hh:mm:ss")
Me.CboStaffName.SetFocus
Me.txtVlu.Visible = False
Me.Label7.Visible = False
Me.Label8.Visible = False
Me.CboICreferer.Visible = False
End Sub
**********************
Please help.
Thx
Matthew
I've got a user form through which I am accepting various inputs & when I
click on the 'add record' button the data gets copied onto rows everytime. Is
there anything that i can do to automatically ensure the rows (after
updating) gets protected ?
I cant protect the sheet directly in this case, cos the user feeds thru the
form will not get copied to the database table then.
This is how my code currently looks.
*****************************
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data_Dump")
'Find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
' Check for incomplete entries before 'Adding Recod'
If Trim(Me.CboStaffName.Value) = "" Then
Me.CboStaffName.SetFocus
MsgBox "Please enter Staff Name"
Exit Sub
End If
' To Copy the data to the database
ws.Cells(iRow, 1).Value = Me.Txtdate.Value
ws.Cells(iRow, 2).Value = Me.Txttime.Value
' Clear the data
Me.Txtdate.Value = Format(Date, "dd-mmm-yy")
Me.Txttime.Value = Format(Time, "hh:mm:ss")
Me.CboStaffName.SetFocus
Me.txtVlu.Visible = False
Me.Label7.Visible = False
Me.Label8.Visible = False
Me.CboICreferer.Visible = False
End Sub
**********************
Please help.
Thx
Matthew