Click to See Complete Forum and Search --> : Data Grid
casox
Dec 29th, 1999, 12:38 AM
I'm working with a DataGrid in VB 6.0. I have displayed the desired data in the grid and have selected a particular record. Now, I want to transfer the value of that record, including all of it's fields, back to my original form which has the same corresponding fields. Can you tell me the names of those constants and how to tranfer? Thanks,
casox
Clunietp
Dec 29th, 1999, 12:42 AM
Possibility:
On the grid_doubleclick event, retrieve the Primary key field in your data control and return it to a global variable. (glngCustID = rs.fields("CustID").value)
Unload the grid form, and query your db for that primary key and display it in your controls on your main form.
data1.recordsource = "Select * from MyTable where CustID = " & glngCustID
data1.refresh
casox
Dec 29th, 1999, 12:46 AM
Thanks so much. Greatly appreciated.
casox
casox
Dec 29th, 1999, 01:58 AM
When I try to assign the global variable the value of rs.Fields("IssueNum").value it gives me an "Object required" error. my exact statement looks like this: glIssueNum = rs.Fields("IssueNum").value I've also set glIssueNum in the form as Public glIssueNum as Integer. Why? Thanks,
casox
casox
Dec 29th, 1999, 04:23 AM
OK, although this solution gives me the value of "a" field, it does not give me the value of the selected field. Is the selected record automatically loaded into the current data control? Or is there another way to obtain the values of the fields?
casox
Clunietp
Dec 29th, 1999, 09:10 AM
When you click on a field in the grid, it will automatically scroll the data control to the record that you have selected on the grid.
You can retrieve the value of the selected field using this code
DataGrid1.Columns(DataGrid1.Col).Text
HTH
Tom
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.