[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.
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?
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.
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:
query = "Update Jobs Set Progress = " & FlexGrid.TextMatrix(5,1) & " VALUES ('" & FlexGrid.TextMatrix(5,7) & "')"
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:
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).
Re: Identify cell in msflexgrid to enable saving
Ooops! Sorry for the terrible sample code.
Thanks si_the_geek for setting it straight.
Re: Identify cell in msflexgrid to enable saving
No problem, I could see what you meant!
Re: Identify cell in msflexgrid to enable saving