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

Click on a DataGrid

Status
Not open for further replies.

CooterBrown

IS-IT--Management
Aug 17, 2001
125
US
I am building a datagrid from a table we have on our midrange system. The grid is loading fine but what I want to do is depending on the row that is clicked populate a few text boxes with a couple of feilds in the table. how can I do that?

Private Sub Form_Load()

'On Error GoTo ErrorHandler
Dim Connection As New ADODB.Connection


Dim Records As New ADODB.Recordset


'important against as400

Connection.ConnectionString = "Provider=IBMDA400.DataSource.1;User ID=;Data Source=System;Transport Product=Client Access;SSL=DEFAULT"

Connection.CursorLocation = adUseClient
Connection.Open

Records.Open "SELECT * FROM Table", Connection, adOpenStatic, adLockOptimistic


Set DataGrid1.DataSource = Records


Form1.Show

End Sub
 
Hi,

You might want to give this a try, from the VB help files on the DataGrid:

Returning Values from the DataGrid
Once the DataGrid is connected to a database, you may want to monitor which cell the user has clicked. Use the RowColChange event — not the Click event — as shown below:

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
' Print the Text, row, and column of the cell the user clicked.
Debug.Print DataGrid1.Text; DataGrid1.Row; DataGrid1.Col
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top