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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flex Grid navigation

Status
Not open for further replies.

dlpastel

Programmer
Aug 8, 2002
114
US
I want to be able to move through a Ado recordset that I have assigned to a flexgrid so that if I click on a cel, the recordset moves to that particular record.

So far, I have been able to create the recordset and
assign it to the flex grid but that is where I get stuck
StrSql = "Select CustName, CustPhone from Customers"
Set rsBrowse = New ADODB.Recordset
rsBrowse.Open StrSql, dbCTS(Cust), adOpenKeyset, adLockOptimistic
Set fMainForm.gridBrowse.DataSource = rsBrowse

Now how do I make the recordset move to the record on the cel I click?


Thanks,
Dan
 
The description is a little vague so my reply might be as well. Sorry about that.

Use the flexgrid click event.
the flexgrid should return the text of the item that the user clicked on. flexgrid.text or something like that. Then search the database based upon the flexgrid.text and if you have databound controls to the ado connection it should go right to that selection.

Hope I helped instead of making things more complicated.
~paul
 
Look for a key field to search for in your recordset. I don't think that there is any need to go back to the database if you have the recordset already. Just loop through it looking for the key field.

The click event also can retuirn the row of the flexgrid. So you may be able to loop through the recordset a number of times equal to the row value to get to the recordset. Watch out for any off-by-one error. Something like this might work it your grid is filled in the order of your recordset, but I have never tried it.

rs.movefirst
for i=1 to msflexgrid1.row
rs.movenext
next i

Otherwise you will need to search for a key value.

rs.movefirst
do until rs.eof
if rs![keyfield]=msfglexgrid1.textmatrix(msflexgrid1.row,keycol) then exit loop
loop

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top