Hello everyone,
I am new to vb 6.0 and trying to build an inventory software. in the stock entry form I used a MSHFlexgrid, 10 text box and a add button. I want to various items in ten txtboxes and each time a click the add button it will be added to the MSHFlex grid and then I will create another save button to save the total data to a access database. But the problem is I can't add more then one rows containing the data in the MSHFlexgrid. Whenever I put the nex series of data and click the add button it replace the first row data of MSHFlexgrid. Here is my code for the add button. By the way I used one sub procudure calling "InitGrid" and make the grid when the form loads.
Private Sub cmdAdd_Click()
With grid
If .Rows = 2 And .TextMatrix(1, 10) = "" Then
.TextMatrix(1, 1) = txtinv.Text
.TextMatrix(1, 2) = txtinvdate.Text
.TextMatrix(1, 3) = cmbcompany.Text
.TextMatrix(1, 4) = cmbcatagory.Text
.TextMatrix(1, 5) = txtpcs.Text
.TextMatrix(1, 6) = txtbdate.Text
.TextMatrix(1, 7) = txtbprice.Text
.TextMatrix(1, 8) = txttag.Text
.TextMatrix(1, 9) = txtcode.Text
.TextMatrix(1, 10) = txtdescription.Text
Else
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 1) = txtinv.Text
.TextMatrix(.Rows - 1, 2) = txtinvdate.Text
.TextMatrix(.Rows - 1, 3) = cmbcompany.Text
.TextMatrix(.Rows - 1, 4) = cmbcatagory.Text
.TextMatrix(.Rows - 1, 5) = txtpcs.Text
.TextMatrix(.Rows - 1, 6) = txtbdate.Text
.TextMatrix(.Rows - 1, 7) = txtbprice.Text
.TextMatrix(.Rows - 1, 8) = txttag.Text
.TextMatrix(.Rows - 1, 9) = txtcode.Text
.TextMatrix(.Rows - 1, 10) = txtdescription.Text
.Rows = .Rows - 1
End If
End With
End Sub
Somebody please help. I am totally lost.
Thanks in advance.