Results 1 to 2 of 2

Thread: Datagrid buttonclick event

  1. #1

    Thread Starter
    Addicted Member smh's Avatar
    Join Date
    Oct 2000
    Location
    South Dakota, USA
    Posts
    249

    Datagrid buttonclick event

    I am using the datagrid to show some information about a person, but I have a password field that can not be shown in the datagrid for security reasons. I need to enable it so that when the user clicks on the row of the person whose password they need to verify, it will pop up in a seperate textbox. I am pretty sure that this would need to be done in the buttonclick event. This would be the query that I need to use to find the correct password:

    "SELECT * FROM AuthorizationInformation " & _
    "WHERE lastname = ****COL1CURRENTROW " & _
    "AND firstname = ****COL0CURRENTROW " & _
    "AND companyname = ****COL2CURRENTROW' ;", cnn,adOpenKeyset, adLockOptimistic


    I don't know how to select the cells in the current row, to do a query on it. Anybody know how to do this?
    Normal is boring...

    smh

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    smh here ya are:

    1) Add a combo box to your form. And fill it with all your details you want! This is relative to the colum it's going to appear in!

    2) Here's some code! Try this change relative names though!
    Like combo1, datagrid name, field name etc.

    Private Sub Form_Load()
    'dbg is the name of the dbgrid.
    dbg.Columns("InsertNameHere").Button = True
    End Sub

    Private Sub dbg_ButtonClick(ByVal ColIndex As Integer)
    If ColIndex = 1 Then ' refering to 2nd column. 1st colmn is 0
    Combo1.Top = dbg.Top + dbg.RowTop(dbg.Row) + dbg.RowHeight
    Combo1.Left = dbg.Left + dbg.Columns(ColIndex).Left
    ' Width and Height properties can be set a design time
    ' The width of the list does not have to be the same as the width of the grid column
    Combo1.Width = dbg.Columns("InsertNameHere").Width 'again companyname is field name
    Combo1.Visible = Not Combo1.Visible
    If Combo1.Visible Then
    Combo1.Text = dbg.Text
    Combo1.ZOrder ' make sure the list is on top of the grid
    End If
    End If
    End Sub

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