Results 1 to 8 of 8

Thread: [RESOLVED] Identify cell in msflexgrid to enable saving

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    41

    Resolved [RESOLVED] Identify cell in msflexgrid to enable saving

    I am trying to get the selected cell contents from a msflexgrid into an msaccess tbl. With this code it is added into the correct column, but as a new record.

    Private Sub Command1_Click()

    Text1.Text = MSFlexGrid1
    query = "INSERT INTO Jobs (Progress) VALUES ('" & Text1 & "')"
    Set rs = DBCon.Execute(query)
    End Sub

    How can I identify which record it belongs to, as in order to edit it the focus is in the one cell only.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Identify cell in msflexgrid to enable saving

    Do you mean update the selected row of the flexgrid? Does it have any ID or any unique identifying data?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    41

    Re: Identify cell in msflexgrid to enable saving

    My flex grid has 7 columns the first is the Job_Id and the last column,"Progress" needs to be edited at times and the changes in the particular cell I need to get back to the tble aligned with the correct record. I can't work out how to reference the Job_Id . Do move the focus back to the Job_Id.
    Last edited by waldos; Jul 22nd, 2005 at 05:32 AM.

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Identify cell in msflexgrid to enable saving

    The FlexGrid.TextMatrix property allows you to access the contents of any cell without moving focus to that cell.


    VB Code:
    1. query = "Update Jobs Set Progress = " & FlexGrid.TextMatrix(5,1) & " VALUES ('" & FlexGrid.TextMatrix(5,7) & "')"

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Identify cell in msflexgrid to enable saving

    There is a problem with brucevde's example, (unusually for him) he posted the wrong syntax. It should be:
    VB Code:
    1. query = "Update Jobs Set Progress = '" & FlexGrid.TextMatrix(FlexGrid.Row,[b]7[/b]) & "' WHERE job_id = " & FlexGrid.TextMatrix(FlexGrid.Row,[b]1[/b])

    Note that the column numbers 7 and 1 may not be right, you may need to swap them for 6 and 0 (the numbers 7 and 1 assume you have a fixed column in your grid).

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Identify cell in msflexgrid to enable saving

    Ooops! Sorry for the terrible sample code.

    Thanks si_the_geek for setting it straight.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Identify cell in msflexgrid to enable saving

    No problem, I could see what you meant!

  8. #8

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    41

    Re: Identify cell in msflexgrid to enable saving

    Thank You.

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