Dubble click on a datagrid 
Author Message
 Dubble click on a datagrid
I have a datagrid and the only way I can make it work is to have the ID
field in the database as one of the display fields. If they click on any
other field it returns the value of that field. I want it to return the
value of that record ID no matter which field they click. Please help if you
know how to do this!!!

Thanks in advance!!!

Here is my code.

Dim strSql As String
Set mrsCust = New ADODB.Recordset
    mrsCust.LockType = adLockOptimistic
    mrsCust.CursorType = adOpenKeyset

strSql = "SELECT ID, HospitalName, city FROM tHospitals WHERE HospitalName
is not Null and HospitalName <> 'NO  HOSPITAL'"
    mrsCust.Source = strSql
    Set mrsCust.ActiveConnection = cn
    mrsCust.Open

Set DataGrid3.DataSource = mrsCust



Fri, 28 Jan 2005 05:36:01 GMT  
 Dubble click on a datagrid
To get the ID value in the DBClick, you can use following code:

Private Sub DataGrid1_DblClick()

MsgBox  mrsCust.Fields("id").Value

End Sub

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Fri, 28 Jan 2005 11:12:57 GMT  
 Dubble click on a datagrid
THANKS!!!!

I am not sure I understand. I do that

Private Sub DataGrid1_DblClick()

But I still get returned the data of the field they click on. Example if
they click on the ID field everything is fine but if they click on the name
or  the address field it returns what ever data is in that field. What am I
missing?

    Rick



Quote:
> To get the ID value in the DBClick, you can use following code:

> Private Sub DataGrid1_DblClick()

> MsgBox  mrsCust.Fields("id").Value

> End Sub

> Luke

> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)



Fri, 28 Jan 2005 11:38:52 GMT  
 Dubble click on a datagrid
Reallly? when we call:

MsgBox  mrsCust.Fields("id").Value

it should return the value of field "id".

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Fri, 28 Jan 2005 14:55:18 GMT  
 Dubble click on a datagrid
Ok I get it Daaaaa. Thanks!!!!

I still have two problems though. 1 After the{*filter*}time I double click it
till returns the same row as the when I double clicked the{*filter*}time even if
I click on another line. 2 How do I heal the ID column in the datagrid.



Quote:
> Reallly? when we call:

> MsgBox  mrsCust.Fields("id").Value

> it should return the value of field "id".

> Luke

> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)



Fri, 28 Jan 2005 15:45:42 GMT  
 Dubble click on a datagrid
Sorry never mind I figured it out.

    Rick

Thanks for all your help!!


Quote:
> Ok I get it Daaaaa. Thanks!!!!

> I still have two problems though. 1 After the{*filter*}time I double click it
> till returns the same row as the when I double clicked the{*filter*}time even
if
> I click on another line. 2 How do I heal the ID column in the datagrid.



> > Reallly? when we call:

> > MsgBox  mrsCust.Fields("id").Value

> > it should return the value of field "id".

> > Luke

> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)



Fri, 28 Jan 2005 15:52:10 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Need some help with DataGrids (DataGrid-->DataGrid, DataGrid-->Dataset, DataGrid-->XML)

2. Auto Saving an editable datagrid without click the save/update grid button

3. Datagrid combo box or right mouse click

4. Column Value of a Clicked/Selected Row in a DataGrid

5. Datagrid double click

6. Right Click on a DataGrid

7. First Click In UserControl DataGrid Does Not Fire An Event

8. Retrieving a DataRow from a DataSet when a user clicked on a DataGrid bound to it

9. Double click in datagrid

10. DataGrid Button Click

11. Click event of a datagrid

12. HELP - Click on DataGrid...

 

 
Powered by phpBB® Forum Software