Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 30th, 2003, 10:38 AM
ric ric is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Venice
Posts: 4 ric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
MSFlexGrid correct row updated

Hy All!
I have following code in my MSFlexGrid, which does not update the row in the correct cell, but always in the cell of first row.
In the MSFlexgrid I can type and change the value without any problem, but once saved the grid (and the recordset too) show me updated the value of the correct column, but whatever row has been changed in typing, the new value appears always in the first row (correct column, but wrong row).

This is in form load():
-----------------------

Dim rs As Recordset

With rs

.MoveLast
MSFlexGrid4.Rows = .RecordCount
MSFlexGrid4.Cols = 3
MSFlexGrid4.FixedCols = 0

.MoveFirst
Do
MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 1) = !Item
MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 2) = !charge
.MoveNext
Loop Until .EOF
End With

And this is the command to save the changes
------------------------------------------------------

If Not txtDataEntry.Visible Then Exit Sub
If txtDataEntry.Text <> MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, _
MSFlexGrid4.col) Then
cmdSave.Enabled = True
End If

MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, MSFlexGrid4.col) = _
txtDataEntry.Text
txtDataEntry.Visible = False

With rs.Recordset

.Edit
!charge = txtDataEntry.Text
!Item = txtDataEntry.Text
.Update

End With

Anyone can help me to rebuild this code and have the recordset updated in the correct row instead constantly in row(1) ?

Thanks in advance.

Reply With Quote
  #2  
Old August 30th, 2003, 11:16 AM
zak2zak zak2zak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Singapore
Posts: 34 zak2zak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to zak2zak
Lightbulb Update MSFlexGrid Row...

May be this helps....
Do U Have FixRow?
I assume that U have 1 FixedRow because U want the first record
to be at row 1:
MSFlexGrid4.TextMatrix(.AbsolutePosition + 1, 1) = !Item
Code:
This is in form load(): 
----------------------- 
Dim i As Integer
Dim rs As Recordset 

'Where is rs set to the recordset?

With rs 
.MoveLast 
MSFlexGrid4.Rows = .RecordCount  + 1
MSFlexGrid4.Cols = 3 
MSFlexGrid4.FixedCols = 0 

.MoveFirst 
For i = 1 To MSFlexGrid4.Rows -1
'Its good to set Col 0 to the AbsolutePosition of rs
MSFlexGrid4.TextMatrix(i, 0) = .AbsolutePosition
MSFlexGrid4.TextMatrix(i, 1) = !Item 
MSFlexGrid4.TextMatrix(i, 2) = !charge 
.MoveNext 
Next i
End With 

And this is the command to save the changes 
------------------------------------------------------ 

If Not txtDataEntry.Visible Then Exit Sub 
If txtDataEntry.Text <> MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, _ 
MSFlexGrid4.col) Then 
cmdSave.Enabled = True 
End If 

MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, MSFlexGrid4.col) = _ 
txtDataEntry.Text 
txtDataEntry.Visible = False 

With rs.Recordset 
.AbsolutePosition = MSFlexGrid4.TextMatrix(MSFlexGrid4.Row, 0) 
.Edit 
!charge = txtDataEntry.Text 
!Item = txtDataEntry.Text 
.Update 
End With 
__________________
I May Have Misinterpret U'r Post
Correct Me If I Am Wrong......//
Enjoy Coding..........................///

zak2zak

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > MSFlexGrid correct row updated


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway