how to edit a record in database by using vb6, i don't any clue :(

What database are you using, msaccess, sql, mysql?
What connection are you using, data control or ADO?

ms access
ado po

Dim conn as ADODB.Connection
Dim Rs As ADODB.Recordset

Set conn = new ADODB.Connection
Set Rs = New ADODB.Recordset

'Do your connection to access code here

Rs.Open "SELECT * FROM MyTable", conn, adOpenStatic, adLockOptimistic

Rs!Fieldname1 = Text1.Text
Rs.Update

And that is it...:)

'Do your connection to access code here

connection? example po

Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\YourDatabaseName.MDB;Persist Security Info=False"

will this edit the highlighted record?

Private Sub Toolbar_ButtonClick(ByVal Button As MSComctlLib.Button)

What do you mean with "highlighted record"? Where is it highlighted?

The code above will edit an existing record that you have chosen.

I also do not understand your picture, what is it suppose to show?

error about this

Private Sub Toolbar_ButtonClick(ByVal Button As MSComctlLib.Button)

What is the code under this (below)?

Private Sub Toolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.Index = 1 Then
frmList.Show
End If
If Button.Index = 2 Then
frmReserve.Show
End If
If Button.Index = 3 Then
    frmList.Adodc.Refresh
    frmList.DataGrid.Refresh
End If
If Button.Index = 4 Then

Dim conn As ADODB.Connection
Dim Rs As ADODB.Recordset

Set conn = New ADODB.Connection
Set Rs = New ADODB.Recordset

conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database1.mdb;Persist Security Info=False"

Rs.Open "SELECT * FROM List", conn, adOpenStatic, adLockOptimistic

Rs!CustomerName = txtName.Text
Rs!ContactNumber = txtContact.Text
Rs.Update
End If
End Sub

Don't put the the code in the toolbar.

Place it in your command button (cmdUpdate) in your Modify form.

Your code is porfect. Reference the ms active x data objects.:)

my modify command button is on the toolbar

when i click modify

Do you have a control named txtName on your form?

yes

Then your problem lies with the field name CustomerName. Is that spelled correctly. It is not the recordset, that was declared etc. Is your open call correct, in other words the table name List exists?

yes the table name List exist

I'll test this from your app, and will paste back here again.:)

have you figure it out?

The reference to txtName and all the other controls below that is on yout frmReview. You have to addfrmReview before the control names -

Rs!Name = frmReview.txtName.Text

Your other problem is that it will update the database with empty strings, because all of the textboxes is empty. You need to put the in frmReview for it to work. First check if the user has added all text needed and THEN update the database.:)

frmReserve? i will put frmReserve in all txtName.txt?

Have a look at your toolbar, click event AND your module, I've added some code there. It is all working fine, just mark this as solved thanks.:)

how to edit a record in database by using vb6, i don't any clue :(

you are newbie to daniweb , so i would suggest you to read its rules

post your questions ( including your efforts ) to new thread.

this is great effort and work for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.