By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

Clearing MSHFlexgrid's data

P: 39
Hi,
I have a minor trouble in my program. I've one MSHFlexgrid to show all datas from an input form that I made. The problem occurs when I deleted one or more rows in the MSHFlexgrid and would like to add a new data in that MSHFlexgrid. Example: I have 3 rows of data in the MSHFlexgrid, I deleted them all. The deleted datas were gone just fine, but when I entered a new one, MSHFlexgrid shows it in row 4 instead of row 1 (row 1 to 3 are blank). How to make MSHFlexgrid's Row Index back to first row after I deleted the data?

With MSHFlexGrid1
.Clear
.Refresh
End With
(I think I missed something here)

Thank you for your help!
Nairda
Jun 8 '07 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
Hi,
I have a minor trouble in my program. I've one MSHFlexgrid to show all datas from an input form that I made. The problem occurs when I deleted one or more rows in the MSHFlexgrid and would like to add a new data in that MSHFlexgrid. Example: I have 3 rows of data in the MSHFlexgrid, I deleted them all. The deleted datas were gone just fine, but when I entered a new one, MSHFlexgrid shows it in row 4 instead of row 1 (row 1 to 3 are blank). How to make MSHFlexgrid's Row Index back to first row after I deleted the data?
Expand|Select|Wrap|Line Numbers
  1.     With MSHFlexGrid1
  2.            .Clear
  3.            .Refresh
  4.     End With
  5.  
(I think I missed something here)

Thank you for your help!
Nairda
How's this:

Expand|Select|Wrap|Line Numbers
  1. Dim NombreID As Integer
  2. Dim GrinSQL As String
  3. Dim fieldsDelete As New ADODB.Recordset 
  4.    NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 5)) '  
  5.    GrinSQL = "select * from YourTableName where id = " + CStr(NombreID)     
  6.    Call fieldsDelete.Open(GrinSQL, cn, 2, 3)    
  7.    fieldsDelete.Delete    
  8.    fieldsDelete.Close    
  9.    Set fieldsDelete = Nothing 
  10.  
I am not sure how many columns you have. Aboce shoudl help handle 5 columns NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 5)) '

Give this a whirl, and see what works...
Jun 8 '07 #2

P: 39
How's this:

Expand|Select|Wrap|Line Numbers
  1. Dim NombreID As Integer
  2. Dim GrinSQL As String
  3. Dim fieldsDelete As New ADODB.Recordset 
  4.    NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 5)) '  
  5.    GrinSQL = "select * from YourTableName where id = " + CStr(NombreID)     
  6.    Call fieldsDelete.Open(GrinSQL, cn, 2, 3)    
  7.    fieldsDelete.Delete    
  8.    fieldsDelete.Close    
  9.    Set fieldsDelete = Nothing 
  10.  
I am not sure how many columns you have. Aboce shoudl help handle 5 columns NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 5)) '

Give this a whirl, and see what works...
Thank you, Dokoll.
But there's an error message "Subscript out of range" on:
NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 11)).
I've 11 columns, so i've changed the code a bit.

Is there any easier way to completely cleared the MSHFlexgrid? Because MSHFlexgrid.clear or MSHFlexgrid.refresh doesn't make the MSHFlexgrid to start from the first row if I enter a new data after deleting the old ones.

Thank you very much!
NAIRDA
Jun 8 '07 #3

100+
P: 375
Thank you, Dokoll.
But there's an error message "Subscript out of range" on:
NombreID = CInt(mFlex.TextMatrix(mFlex.Row, 11)).
I've 11 columns, so i've changed the code a bit.

Is there any easier way to completely cleared the MSHFlexgrid? Because MSHFlexgrid.clear or MSHFlexgrid.refresh doesn't make the MSHFlexgrid to start from the first row if I enter a new data after deleting the old ones.

Thank you very much!
NAIRDA
Hello Nairda

I am using MSHFlexgird only to dispaly. eg. When a user selects a district it will display all the products available in the same. If the user selects another district the previous values are removed and new values of the same are displayed.

May be you require a little alteration in my code. The code below clears and sets the order
MSHFlexGrid1.Clear
MSHFlexGrid1.Rows = 1
MSHFlexGrid1.Cols = 1
'Change the col as per your requirement
Before you write your display code write the above three lines and proceed with your coding, And kindly let us know if its working
Jun 8 '07 #4

P: 39
Hello Nairda

I am using MSHFlexgird only to dispaly. eg. When a user selects a district it will display all the products available in the same. If the user selects another district the previous values are removed and new values of the same are displayed.

May be you require a little alteration in my code. The code below clears and sets the order
MSHFlexGrid1.Clear
MSHFlexGrid1.Rows = 1
MSHFlexGrid1.Cols = 1
'Change the col as per your requirement
Before you write your display code write the above three lines and proceed with your coding, And kindly let us know if its working

Hello to you too, cmrhema.
Thanks for the reply.
Yes, I also use the MSHF for displaying the data. The difference is My MSHF displays the data from an input form (My MSHF works like a selling receive record. It contains Date of Transaction, Amount, and Quantity of merchandise sold). So, if you fill the input form and then clicked a "SAVE" command button, VB will add a new data in both MSHF and database. The problem is, if I cleared the MSHF (Canceling the transaction by clicking a "CANCEL" button) and then added another input and then I clicked the "SAVE" button once again, the data will be displayed in the 2nd row of the MSHF and left the 1st row blank (Its belongs to the 1st data that I've already deleted)
I can't find a way how to return the MSHF's row index, so if I clicked the "SAVE" button, it'll show the data in the 1st row.

I've tried your code, but there's another problem: It sets the MSHF row to 1 so if I entered two kind of mercandise sold in one MSHF, VB will show an error message "Subscript out of range" because MSHF only has 1 row and my input needs 2 rows.
But its works very well if I only done an input action one at a time.

Thank you very much for your help.
NAIRDA
Jun 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.