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.

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

That is because you are telling the grid to place your data in the first row....>

.TextMatrix(1, 1) = txtinv.Text

It works like this - .Textmatrix(Row to put data, Column to put data) = The data. You need to change the first 1 to whichever row you want to add the data i.e .Textmatrix(5,1) = txtinv

thx andreret for the reply. But I am using an If and in the else part I am telling vb to put the next data in to the next row. do I make it clear ? or as I understand from your post that my code should be like .textmatrix(2,1) = txtinv.text, .textmatrix (2,2) = txtinvdate.text, like that ?? If this is the way, then what should I right in the "Else" part of the code ??

Hi,

Change Line Number 26:

.Rows = .Rows - 1

make it:
.Row = .Rows - 1

Regards
Veena

Thanks veena, it works for me.
I am now making the sales invoice of the program, should I post my question in another post ?

Hi,

Mark this thread as 'Solved"
and post a new question...

Regards
Veena

how then could i find it..pls..

@cheriesp, this thread belongs to someone else and you are VERY vague at what you need. Please open your OWN thread from HERE.

You also need to tell us what you want to find, we can not read minds here. :)

My apologies, just saw your new thread, please ignore above comment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.