R
rixanna
I'm working on a simple program that enabled the user to Search and
Edit the data. The user has 2 options whether to save the data as a new
record or to replace the existing data.
I managed to get the job done for the user to SAVE AS NEW RECORD by
using this coding :
ActiveCell.Value = txtSpecificationNo.Value
ActiveCell.Offset(0, 1) = txtIssueNo.Value
ActiveCell.Offset(0, 2) = lblPly1.Caption
ActiveCell.Offset(0, 3) = txtQtyPly.Value
ActiveCell.Offset(0, 4) = txtCodePly.Value
ActiveCell.Offset(0, 5) = txtLengthPly.Value
ActiveCell.Offset(0, 6) = txtWidthPly.Value
ActiveCell.Offset(0, 7) = txtBiasVolPly.Value
ActiveCell.Offset(0, 9) = txtBuildingInstructionPly.Value
ActiveCell.Offset(0, 10) = txtRevisionPly.Value
Range("A2").Select
End If
The problem now is that I don't know what should I write to let the
user save, as to replace the existing data.
For the time being, I used this code and it did replace the existing
data but it copies the data for 3 to 5 times. So, there are 5 rows of
the same data in the worksheet.
ActiveCell.Value = txtSpecificationNo.Value
ActiveCell.Offset(0, 1) = txtOne.Value
ActiveCell.Offset(0, 2) = lblPly.Caption
ActiveCell.Offset(0, 3) = txtQty.Value
ActiveCell.Offset(0, 4) = txtCode.Value
ActiveCell.Offset(0, 5) = txtLength.Value
ActiveCell.Offset(0, 6) = txtWidth.Value
ActiveCell.Offset(0, 7) = txtBiasVol.Value
ActiveCell.Offset(0, 8) = txtWeight.Value
ActiveCell.Offset(0, 9) = txtBuildingInstruction.Value
ActiveCell.Offset(0, 10) = txtRevision.Value
For i = 2 To 20
If Worksheets("BOOK TABLE").Cells(i, 1).Value = txtSpecificationNo.Text
Then
Worksheets("BOOK TABLE").Cells(i, 2).Value = txtIssue.Text
Worksheets("BOOK TABLE").Cells(i, 3).Value = lblPly.Caption
Worksheets("BOOK TABLE").Cells(i, 4).Value = txtQty.Text
Worksheets("BOOK TABLE").Cells(i, 5).Value = txtCode.Text
Worksheets("BOOK TABLE").Cells(i, 6).Value = txtLength.Text
Worksheets("BOOK TABLE").Cells(i, 7).Value = txtWidth.Text
Worksheets("BOOK TABLE").Cells(i, 8).Value = txtBiasVol.Text
Worksheets("BOOK TABLE").Cells(i, 9).Value = txtWeight.Text
Worksheets("BOOK TABLE").Cells(i, 10).Value =
txtBuildingInstruction.Text
Worksheets("BOOK TABLE").Cells(i, 11).Value = txtRevision.Text
End If
Next i
Can somebody help me?
Thank you in advanced.
Edit the data. The user has 2 options whether to save the data as a new
record or to replace the existing data.
I managed to get the job done for the user to SAVE AS NEW RECORD by
using this coding :
ActiveCell.Value = txtSpecificationNo.Value
ActiveCell.Offset(0, 1) = txtIssueNo.Value
ActiveCell.Offset(0, 2) = lblPly1.Caption
ActiveCell.Offset(0, 3) = txtQtyPly.Value
ActiveCell.Offset(0, 4) = txtCodePly.Value
ActiveCell.Offset(0, 5) = txtLengthPly.Value
ActiveCell.Offset(0, 6) = txtWidthPly.Value
ActiveCell.Offset(0, 7) = txtBiasVolPly.Value
ActiveCell.Offset(0, 9) = txtBuildingInstructionPly.Value
ActiveCell.Offset(0, 10) = txtRevisionPly.Value
Range("A2").Select
End If
The problem now is that I don't know what should I write to let the
user save, as to replace the existing data.
For the time being, I used this code and it did replace the existing
data but it copies the data for 3 to 5 times. So, there are 5 rows of
the same data in the worksheet.
ActiveCell.Value = txtSpecificationNo.Value
ActiveCell.Offset(0, 1) = txtOne.Value
ActiveCell.Offset(0, 2) = lblPly.Caption
ActiveCell.Offset(0, 3) = txtQty.Value
ActiveCell.Offset(0, 4) = txtCode.Value
ActiveCell.Offset(0, 5) = txtLength.Value
ActiveCell.Offset(0, 6) = txtWidth.Value
ActiveCell.Offset(0, 7) = txtBiasVol.Value
ActiveCell.Offset(0, 8) = txtWeight.Value
ActiveCell.Offset(0, 9) = txtBuildingInstruction.Value
ActiveCell.Offset(0, 10) = txtRevision.Value
For i = 2 To 20
If Worksheets("BOOK TABLE").Cells(i, 1).Value = txtSpecificationNo.Text
Then
Worksheets("BOOK TABLE").Cells(i, 2).Value = txtIssue.Text
Worksheets("BOOK TABLE").Cells(i, 3).Value = lblPly.Caption
Worksheets("BOOK TABLE").Cells(i, 4).Value = txtQty.Text
Worksheets("BOOK TABLE").Cells(i, 5).Value = txtCode.Text
Worksheets("BOOK TABLE").Cells(i, 6).Value = txtLength.Text
Worksheets("BOOK TABLE").Cells(i, 7).Value = txtWidth.Text
Worksheets("BOOK TABLE").Cells(i, 8).Value = txtBiasVol.Text
Worksheets("BOOK TABLE").Cells(i, 9).Value = txtWeight.Text
Worksheets("BOOK TABLE").Cells(i, 10).Value =
txtBuildingInstruction.Text
Worksheets("BOOK TABLE").Cells(i, 11).Value = txtRevision.Text
End If
Next i
Can somebody help me?
Thank you in advanced.