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

Pop-up Display of DBGrid Row

Status
Not open for further replies.

Linguist

Technical User
Jul 11, 2000
40
US
Background: I created a database using the DBGrid to display 6 fields of data. The user has to resize the columns in order to see all the text in each field.

Question: I would like to create a form that would pop-up when the user clicks on a row and display the data in each field of that row (and just that row) in corresponding text boxes on the pop-up form.

Thanks for your help.
-Linguist
 
Try this:


Public rec_id As Integer
Private Sub DBGrid1_dblClick()
rec_id = DBGrid1.SelText
frmNewForm.Show
End Sub

Then on your new form, you can do a query against the Database that will select your record based on the item you have selected. On my test, I Displayed the Rec_Id from the database as the first column (this is my Primary Key on the database).

I do this a lot, and what I normally use is a DataGrid (not a DataBase Grid). This uses an ADODC Connection, not a MSRDC. The code is SO much simpilar that would be

frmForm1
Public rec_id As Integer
Private Sub DBGrid1_dblClick()
frmNewForm.Show
End Sub

frmNewForm
Private Form_Load()
txtField1.Text = _
frmForm1.adodc1.Recordset.Fields("Rec_id")
txtField2.Text = _
frmForm1.adodc1.Recordset.Fields("name")
End Sub


Good Luck :)


 

Thanks for the suggestion. I'll try it out.

-Linguist
 
It works!

Thanks again for your help.

-Linguist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top