Martin2k Forums

Board index Visual Basic Visual Basic Help

How to update a record from a FlexGrid?

Ask for help on versions of Visual Basic 6.0 or earlier.

How to update a record from a FlexGrid?

Postby Skate Bart » Tue Jul 03, 2012 1:15 pm

okay.

Here's my problem.
I have a form in which a Microsoft Hierarchical FlexGrid (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.

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
Skate Bart
Newcomer
 
Posts: 3
Joined: Wed Jun 27, 2012 1:35 pm

Re: How to update a record from a FlexGrid?

Postby Keith » Thu Jul 05, 2012 9:55 am

Sorry I haven't replied before I've been watching any replies you've had on vbforums and you haven't had any. I have some Flexgrid apps if you search in My VB Apps database.
I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Image
Keith
Administrator
 
Posts: 869
Joined: Tue Oct 13, 2009 12:15 am
Location: Stoke on Trent, England
Medals: 1
6 Star (1)


Return to Visual Basic Help

Who is online

Users browsing this forum: No registered users and 2 guests