Results 1 to 6 of 6

Thread: Data Grid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92

    Post

    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

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92

    Post

    Thanks so much. Greatly appreciated.

    casox

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92

    Post

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92

    Post

    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

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width