J
Jennifer
This code works great except if the user is trying to change the last row of
data it will not allow the user to change. If you look down my code to
*********** I thought i could put <= LastRow then but when i do this crazy
things start happening to the database. Any ideas? Thank you. Jennifer
Private Sub PutData()
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
Else
MsgBox "Illegal row number"
Exit Sub
End If
If r = 2 Then
With Worksheets("ProduceData")
.Cells(r, 1) = "1"
.Cells(r, 2) = txtInvoice.Value
.Cells(r, 11) = txtFrt.Value
.Cells(r, 3) = txtDate.Value
.Cells(r, 4) = cboVend.Text
.Cells(r, 5) = cboRan.Value
.Cells(r, 7) = txtPallet.Value
.Cells(r, 8) = txtQty.Value
.Cells(r, 9) = txtQtySold.Value
.Cells(r, 10) = txtPrice.Value
.Cells(r, 13) = txtRepakHrs.Value
.Cells(r, 14) = txtRepakQty.Value
DisableSave
End With
Else
If r > 1 And r < LastRow Then ******************
With Worksheets("ProduceData")
.Cells(r, 1) = "=R[-1]C+1"
.Cells(r, 2) = txtInvoice.Value
.Cells(r, 11) = txtFrt.Value
.Cells(r, 3) = txtDate.Value
.Cells(r, 4) = cboVend.Text
.Cells(r, 5) = cboRan.Value
.Cells(r, 7) = txtPallet.Value
.Cells(r, 8) = txtQty.Value
.Cells(r, 9) = txtQtySold.Value
.Cells(r, 10) = txtPrice.Value
.Cells(r, 13) = txtRepakHrs.Value
.Cells(r, 14) = txtRepakQty.Value
DisableSave
End With
Else
MsgBox "Invalid row number"
End If
'select a produce item via button
ActiveSheet.Unprotect
If Me.OptSnap.Value Then
Cells(r, 6).Value = Me.OptSnap.Caption
Else
Cells(r, 6).Value = Me.OptSno.Caption
End If
End If
ActiveSheet.Protect
End Sub
data it will not allow the user to change. If you look down my code to
*********** I thought i could put <= LastRow then but when i do this crazy
things start happening to the database. Any ideas? Thank you. Jennifer
Private Sub PutData()
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)
Else
MsgBox "Illegal row number"
Exit Sub
End If
If r = 2 Then
With Worksheets("ProduceData")
.Cells(r, 1) = "1"
.Cells(r, 2) = txtInvoice.Value
.Cells(r, 11) = txtFrt.Value
.Cells(r, 3) = txtDate.Value
.Cells(r, 4) = cboVend.Text
.Cells(r, 5) = cboRan.Value
.Cells(r, 7) = txtPallet.Value
.Cells(r, 8) = txtQty.Value
.Cells(r, 9) = txtQtySold.Value
.Cells(r, 10) = txtPrice.Value
.Cells(r, 13) = txtRepakHrs.Value
.Cells(r, 14) = txtRepakQty.Value
DisableSave
End With
Else
If r > 1 And r < LastRow Then ******************
With Worksheets("ProduceData")
.Cells(r, 1) = "=R[-1]C+1"
.Cells(r, 2) = txtInvoice.Value
.Cells(r, 11) = txtFrt.Value
.Cells(r, 3) = txtDate.Value
.Cells(r, 4) = cboVend.Text
.Cells(r, 5) = cboRan.Value
.Cells(r, 7) = txtPallet.Value
.Cells(r, 8) = txtQty.Value
.Cells(r, 9) = txtQtySold.Value
.Cells(r, 10) = txtPrice.Value
.Cells(r, 13) = txtRepakHrs.Value
.Cells(r, 14) = txtRepakQty.Value
DisableSave
End With
Else
MsgBox "Invalid row number"
End If
'select a produce item via button
ActiveSheet.Unprotect
If Me.OptSnap.Value Then
Cells(r, 6).Value = Me.OptSnap.Caption
Else
Cells(r, 6).Value = Me.OptSno.Caption
End If
End If
ActiveSheet.Protect
End Sub