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

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
    rs.MoveNext
Loop
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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.