-
I have a datagrid whose datasource is a query returning four fields.
name, startdate, enddate, clientid
Depending on which row is selected (by clicking on any cell in that row) ,i want to assign the clientid of the selected row to a variable. How do i reference this information.
Any help gratefully recieved.
Cheers
-
Are you using a data control to link with the datagrid? If so, selecting a row in the datagrid should automatically move the data control recordset to the corresponding record. Then all you need is:
iClientID = DataControl1.Recordset!ClientID
-
If your not using a data control, I use this little bit of code which has helped me out many times. The important thing in this little bit of code is that you always now which column the clientid will appear. I'm assuming the user will select through a click or doubleclick and that your clientid appears in column 0:
Private Sub Grid_DblClick()
Dim strActiveCell As String
grid.Col = 0
grid.Row = grid.RowSel
strActiveCell = grid.Text
End Sub
I hope that works for you.
flewis
-
Thanks for you help guys. I'm still a liitle stuck though.
My recordset for the datagrid is based on a query.
Flewis i tried to use your piece of code but the compiler doesn't recognise the property .Rowsel of the datagrid.
I'm sure i'm just doing something very stupid, any ideas?