passing data from grid to label

04-20-2004, 01:31 PM
i have a msflexgrid that i want to be able to edit and update records, so when a user clicks a cell in a particular column another form will pop up and they will be able to edit from there, using a textbox.

Upon confirmation of the edit i need to be able to refresh the datagrid, so that the new data shows
i dont have any real probelms as of yet with this so far but...

My question is --- that i need to retrieve the data inside of the cell that has been clicked and display it in another form, so that the user will know what meeds to be edited.
so far my code is:

Private Sub Form_Load()
lblCellvalue.Caption = form1.MSFlexGrid1. 'not sure here
End Sub
any Help appriciated.
Also if anyone can point me to an example of something similar i would be very gratefull. Thanks Dave

04-20-2004, 02:41 PM
Look into the textMatrix() property, this returns the value with a row/cell.

04-20-2004, 07:19 PM
I have now got the label to update from the grid (thanks MKoslof)
. Now im comming to the part of adding/updating a record to the grid. I get an error if the cell selected doesnt have a value inside the field upon selecting an id. Can i insert a value in a specified field where the id matches?

So far i have got this:
Private Sub cmdSave_Click()
With form1.MSFlexGrid1
'= .TextMatrix(.Rowsel, .Colsel)
If rs.EOF = True Then
End If
End With
End Sub

This will add a new record.But i cant get it to update an existing record where an id is which i have specified in an earlier sql select.

04-20-2004, 08:26 PM
I don't think you want to do a with statment regarding your flexGrid. Because based on your code, you aren't doing anything with the grid, you want to add a record to the recordset like so:

'assume rs is open and a valid ADODB recordset

With rs
.Fields("SCR1A_GP_DETAILS_SAME_AS_PATIENT") = txtEdit.Text
End With

set rs = nothing

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum