Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid Click

Status
Not open for further replies.

StormbringerV

Programmer
Nov 21, 2000
15
US
Unusual problem thats vexing.

I'm loading a MSflexgrid from a recordset. It's the last thing done in the form's form_Load(). I'm capturing the grid's click event (Selection is set to row) and at that point loading the information from the grid row into a set of textboxes for editing. ALWAYS, without fail, the FIRST time the user clicks on ANY row, I always get the last record that was loaded. From that point on however, everything works correctly.

Ideas?

Thanks
Dave
 
I know exactly what is hapening. the MSFlex grid is looping through your recordset to fill the grid. Do VB actually sets your recordset to the last record. After your done set rs.MoveFirst. To move to the first record in the recordset, then set the gotfocus to the first item in your flex gride. Then the 2 will match up. Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Hi,

that happens because when you put the data in the grid, the pointer goes to the last position touched(the last row).
i've made some simple code, you can try.

it gives you the possibilitie to add a row and when you click a row, it goes to THAT row you selected.

Private Sub MSFlexGrid1_Click()
Dim response
Dim row_in_case
row_in_case = MSFlexGrid1.Row
MsgBox "rowe:" & row_in_case

response = MsgBox("would you like to add a new row?", vbYesNo, "your title here")
If response = vbYes Then

With MSFlexGrid1
.Rows = .Rows + 1

End With


Else
End If

End Sub

hope this helps,

good work ===================
* Marta Oliveira *
===================
marta100@aeiou.pt
-------------------
CPC_TA- Braga
-------------------
Portugal
===================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top