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

DBGrid issues

Status
Not open for further replies.

napio

Technical User
Aug 9, 2002
6
PE
how do I store the contents of a cell in a dbgrid in a variable when I click on a row? i tried with the following code, but what got stored was the value of the first row, which is selected when the form is loaded...

Private Sub DBGrid1_Click()
varRecord = DBGrid1.Bookmark
Data1.Recordset.Bookmark = varRecord

varRecord = Data1.Recordset.Fields("Field")
End Sub
 
Hi All

I have a similar problem but to make matters difficult, the data in my rows of the DBGrid, have a 2 field index. How do I get VB to recognize the unique key of the 2 fields/columns and to then populate the form with the result?

AussieNut
 
Please people, if you know how to do it, reply to this thread, we need your help!
 
Either:

Private strCellValue As String
Private Sub DBGrid1_Click()
strCellValue = DBGrid1.Columns(DBGrid1.Col).Text
End Sub

Or

Private strCellValue As String
Private Sub DBGrid1_Click()
strCellValue = DBGrid1.Recordset(DBGrid1.Columns(DBGrid1.Col).DataField
End Sub [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top