hello..please help me
i need to edit data using form(user fill in details)..but after editing the record in database.nothing changes happen otherwise it create new row of date databook.Recordset.Edit
databook.Recordset("name") = txtname.Text
databook.Recordset("ic_num") = txtIc.Text
databook.Recordset("room_type") = cboroom.Text
databook.Recordset("check_in") = cbocheckin.Text
databook.Recordset("check_out") = cbocheckout.Text
databook.Recordset("Month") = cbomonth.Text
databook.Recordset("Year") = cboyear.Text

databook.Recordset.Update
databook.refresh

Recommended Answers

All 4 Replies

try this one....maybe it will work. hope so. lol

With databook.Recordset
     .Edit
     !name = txtname.Text
     !ic_num = txtIc.Text
     !room_type = cboroom.Text
     !check_in = cbocheckin.Text
     !check_out = cbocheckout.Text
     !Month = cbomonth.Text
     !Year = cboyear.Text
     .Update
End With
databook.refresh

Here is a code for editing a table on an access database. The logic is there, you just have to edit.

Dim conn As New ADODB.Connection
Dim dbPath As String
Dim strEdit As String

dbPath = "C:\Documents and Settings\coje01\Desktop"

conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbPath & "\Training;Uid=Admin;Pwd=godisgood;"
conn.Open

strEdit = "Update tbluser SET Username = 'JC', Password = 'JC'"
strEdit = strEdit & " Where "
strEdit = strEdit & " UserID = 1 "

conn.Execute strEdit

'First you need to do is to find or search for your unique field
'after searching open ur table for edit
'see my sample code i do hope it will ease your problem
'i use a simple data control but you can subtitute that using adodc

Private sub Edit()
openfindbookchild 'this is the table i open previously DTAFIND is the name of the control that holds the table particularly

dtafind.Recordset.FindFirst "BOOKNUM =" + txtbooknum.Text + ""
If dtafind.Recordset.NoMatch = True Then
Exit Sub 'if no match exit function
Else
'update this book as outbook and display info on the list of books borrowed
dtafind.Recordset.Edit
'insert here now your fields tobe edited
dtafind.Recordset.Update 'dont forget to update
dtafind.recordset.close 'you need to close bcoz table is still open
End if

End Sub

hello..please help me
i need to edit data using form(user fill in details)..but after editing the record in database.nothing changes happen otherwise it create new row of date databook.Recordset.Edit
databook.Recordset("name") = txtname.Text
databook.Recordset("ic_num") = txtIc.Text
databook.Recordset("room_type") = cboroom.Text
databook.Recordset("check_in") = cbocheckin.Text
databook.Recordset("check_out") = cbocheckout.Text
databook.Recordset("Month") = cbomonth.Text
databook.Recordset("Year") = cboyear.Text

databook.Recordset.Update
databook.refresh

have you binded your database fields with these controls such as textbox, combo box,etc.
if your answer is yes, then do the following :-
1. simply navigate though the records to select one using the navigator buttons in your datacontrol.
2. change your data and fire this code :-

Data1.Recordset.Edit
Data1.Recordset.Update
Data1.Refresh

that's all. now navigate through the records once more. you will see the updated ones. now close your program and open the database. you can also see the table is updated.

hope this helps. if not then forward your questions.

regards
Shouvik

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.