Hi,I am new to VB6 and I have displayed records in a DBGrid from access using Data ctrl.

I have displayed name and mailid in the grid
Now,wen I click on any one record,the particular record shoul get selected and corresponding mailid and name should be displayed in another form.
Ten,I wil send mail to that person

9 Years
Discussion Span
Last Post by rucci

use temp textbox and you just call the value of textbox from other form

Private Sub DBGrid1_Click()
With DBGrid1
    .Col = 0 ' start from coloumn 1 
    txtIndex.Text = .Text
End With
Set db = OpenDatabase(App.Path + "\YourDatabaseName.mdb")
Set rs = db.OpenRecordset("YourTableName")
If (rs.RecordCount >= 1) Then
Do While Not rs.EOF
   If rs.Fields("Index") = txtIndex.Text Then
      txtIndex.Text = rs.Fields("Index")
      txtName.Text = rs.Fields("Name")
    Exit Do
    End If
End If

to show in other form use this :

txtNewIndex.text = Form1.txtIndex.text
txtNewName.text = Form1.txtName.text

Hello ,

I am just trying to simply display records in the DB grid from access , i dont know where i am wgoing wrong , i tried to use your code and played about with it but no where . Can you post the code where i need to make a few ammendments and it starts working .

Thanks .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.