|
-
Jul 22nd, 2005, 04:38 AM
#1
Thread Starter
Member
[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.
-
Jul 22nd, 2005, 04:53 AM
#2
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?
-
Jul 22nd, 2005, 05:22 AM
#3
Thread Starter
Member
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.
-
Jul 22nd, 2005, 10:04 AM
#4
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) & "')"
-
Jul 22nd, 2005, 01:57 PM
#5
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).
-
Jul 22nd, 2005, 03:09 PM
#6
Re: Identify cell in msflexgrid to enable saving
Ooops! Sorry for the terrible sample code.
Thanks si_the_geek for setting it straight.
-
Jul 22nd, 2005, 07:17 PM
#7
Re: Identify cell in msflexgrid to enable saving
No problem, I could see what you meant!
-
Jul 22nd, 2005, 08:04 PM
#8
Thread Starter
Member
Re: Identify cell in msflexgrid to enable saving
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|