Results 1 to 4 of 4

Thread: Referencing cells in a datagrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    10

    Question

    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


  2. #2
    Addicted Member P.S.W.'s Avatar
    Join Date
    Aug 2000
    Posts
    146
    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


  3. #3
    New Member
    Join Date
    Oct 2000
    Posts
    5
    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    10

    Unhappy

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width