-
July 3rd, 2012, 07:11 AM
#1
How to update a record from a Flex Grid?
okay.
Here's my problem.
I have a form in which a Microsoft Hierarchical Flex Grid (fgdCompany) is used to display records taken from a database to relevant textboxes on the same form.
When a record from fgdCompany is clicked, then the data in that record is shown on the textboxes.
I have a button called cmdUpdate which should do the following when clicked :
Once, the record is displayed on the text boxes, a change could be made to it.
And when cmdUpdate is clicked it should save the changes it made to that record and display the new updated record on fgdCompany.
My problem is, it always saves the changes made to the first record in fgdCompany. Not the record I want to be changed.
Please help me..... Code used for cmdUpdate is given below.
Code:
Dim rsCompany As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim strSQL As String
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & App.Path & "\Luckshan Tours & Travels.mdb;" & _
"Persist Security Info:False"
cn.Open
strSQL = "SELECT [Company].* FROM [Company]"
rsCompany.Open strSQL, cn, adOpenStatic, adLockPessimistic
rsCompany.Fields("Address") = txtAddress
rsCompany.Fields("Telephone Numbers") = txtTelephoneNo
rsCompany.Fields("Vehicles Registered") = txtVehiclesReg
rsCompany.Update
MsgBox "Changes Saved."
Set fgdCompany.DataSource = rsCompany
rsCompany.Update
-
July 3rd, 2012, 01:31 PM
#2
Re: How to update a record from a Flex Grid?
You're having the same problem as your delete code. The solution will look very similar to the code given that made the delete work.
-
July 4th, 2012, 07:54 AM
#3
Re: How to update a record from a Flex Grid?
You're having the same problem as your delete code. The solution will look very similar to the code given that made the delete work.
I tried it but it didn't work. Can you please send me the code that would work! =)
Would be helping me greatly buddy!!
-
July 4th, 2012, 10:51 AM
#4
Re: How to update a record from a Flex Grid?
You are selecting ALL of the records in the table.
[Company].*
Select the Fields that you will affect. [Company].Address [Company].TelephoneNumber (bad to have a space in field name)
Then, look up a WHERE clause. Where and the Record to update. [Company].RecNum = 42
Then, your code will update THAT record.
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
|