Results 1 to 10 of 10

Thread: getting data from the grid to labels using ADO ****SOLVED****

  1. #1

    Thread Starter
    Lively Member WiseGuy's Avatar
    Join Date
    Apr 2002
    Location
    Zierikzee, The Netherlands
    Posts
    98

    getting data from the grid to labels using ADO ****SOLVED****

    Howdy,

    I'm having some troubles converting my DAO program to an ADO program. Here's the situation:

    The program used to get information from the grid and put it to a few labels on top of the form. That was done by simply fill in the Datasource and the datafield in the properties box. Now that I'm using ADO, I don't have a datacontrol anymore.

    How do I get my data from the grid (MSHFlexgrid) to the labels as I select a record?

    If you need to see any code on how I acces my DB let me know

    WiseGuy
    Last edited by WiseGuy; Apr 26th, 2002 at 04:54 AM.
    I stuck my head out of the window and got arrested for mooning!

    This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
    O/S: Windows XP Professional (dutch)
    Internet: Cable (1Mbit connection)

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Fill in the flexgrid via code (you've done this I expect). Ensure all data you need is in there.

    Hide columns you don't want seen by changing the column width on opening the form/filling the list (Flexgrid.ColWidth(<column number>)=0)

    When the row is selected (by a click) use the click event to grab all the data from the columns to the labels
    VB Code:
    1. lngRowSel = FlexGrid.row '(or RowSel - can't rememebr which)
    2. labeltodisp(0).caption = flexgrid.textmatrix(lngRowSel,0)
    3. labeltodisp(1).caption = flexgrid.textmatrix(lngRowSel,1)
    4. labeltodisp(2).caption = flexgrid.textmatrix(lngRowSel,2)

    Something like that.

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Lively Member WiseGuy's Avatar
    Join Date
    Apr 2002
    Location
    Zierikzee, The Netherlands
    Posts
    98
    Thanks for the code but how do I define 'lngRowSel'
    Is it just a string variable or what?


    WiseGuy
    I stuck my head out of the window and got arrested for mooning!

    This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
    O/S: Windows XP Professional (dutch)
    Internet: Cable (1Mbit connection)

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    VB Code:
    1. Dim lngRowSel as Long

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    Lively Member WiseGuy's Avatar
    Join Date
    Apr 2002
    Location
    Zierikzee, The Netherlands
    Posts
    98
    I get the Error Type mismatch on the second line.

    Any solutions or Ideas?

    WiseGuy
    I stuck my head out of the window and got arrested for mooning!

    This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
    O/S: Windows XP Professional (dutch)
    Internet: Cable (1Mbit connection)

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    The second line - of the one I typed ?

    I assumed you had label controls on there...

    labeltodisp.caption = flexgrid.textmatrix(lngRowSel,0)


    Paste your code up please.


    I am writing from my head, no vb here. Wish I could have it though.

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Lively Member WiseGuy's Avatar
    Join Date
    Apr 2002
    Location
    Zierikzee, The Netherlands
    Posts
    98
    Okey here's the code:

    VB Code:
    1. Private Sub grdDatagrid_Click()
    2. Dim lngRowSel As Long
    3.  
    4. lngRowSel = grdDataGrid.RowSel
    5. grdDataGrid.TextMatrix(lblProcesInstellingId, 1) = lblProcesInstellingId.Caption
    6. grdDataGrid.TextMatrix(lblNaam, 2) = lblNaam.Caption
    7. grdDataGrid.TextMatrix(lblType, 3) = lblType.Caption
    8.  
    9. End Sub

    WiseGuy
    I stuck my head out of the window and got arrested for mooning!

    This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
    O/S: Windows XP Professional (dutch)
    Internet: Cable (1Mbit connection)

  8. #8
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    ummmmmmmmmmmmmmm
    VB Code:
    1. Private Sub grdDatagrid_Click()
    2. Dim lngRowSel As Long
    3.  
    4. lngRowSel = grdDataGrid.RowSel
    5. grdDataGrid.TextMatrix(lblProcesInstellingId, 1) = lblProcesInstellingId.Caption
    6. grdDataGrid.TextMatrix(lblNaam, 2) = lblNaam.Caption
    7. grdDataGrid.TextMatrix(lblType, 3) = lblType.Caption
    8.  
    9. End Sub
    How do I get my data from the grid (MSHFlexgrid) to the labels as I select a record?
    Change to :
    VB Code:
    1. Private Sub grdDatagrid_Click()
    2. Dim lngRowSel As Long
    3.  
    4. lngRowSel = grdDataGrid.RowSel
    5. lblProcesInstellingId.Caption=grdDataGrid.TextMatrix(lngRowSel, 1)
    6. lblNaam.Caption=grdDataGrid.TextMatrix(lngRowSel, 2)
    7. lblType.Caption=grdDataGrid.TextMatrix(lngRowSel, 3)
    8. End Sub


    Vince
    Last edited by Ecniv; Apr 26th, 2002 at 04:42 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  9. #9

    Thread Starter
    Lively Member WiseGuy's Avatar
    Join Date
    Apr 2002
    Location
    Zierikzee, The Netherlands
    Posts
    98
    Thanks that was the trick


    WiseGuy
    I stuck my head out of the window and got arrested for mooning!

    This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
    O/S: Windows XP Professional (dutch)
    Internet: Cable (1Mbit connection)

  10. #10
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    OK, one last thing to help ppl helping others in the forum. Once your post is complete (ie the problem has been solved)
    Look at your posts, on the first one, click edit button (bottom of the first post) then change the topic/title to include "**resolved**" at the end

    Then ppl like me who are ahem *coughboredcough* at work and helping others know that its complete


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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