Selasa, 01 November 2011

Re: [belajar-access] edit recordset

 

lebih ringkas dengan perintah sql:

dim sql as string
sql = "update table2 "
sql = sql & "set id = " & me!text0 & ", nama='" & me!text1 & "', alamat='" & me!text2 & "', kelas='" & me!text3 & "' "
sql = sql & "where project_number=" & me!project_number

currentdb.execute sql

jika dengan recordset operation:
Set db = CurrentDb
Set rs = db.OpenRecordset("table2")
rs.findfirst "[Project_Number] ='" & Me![Project_Number] & "'"
if not rs.nomatch then
rs.edit
rs("id") = Me![text0]
rs("nama") = Me![text1]
rs("alamat") = Me![text2]
rs("kelas") = Me![text3]

rs.Update
end if

rs.Close
set rs = nothing
set db=nothing


aksan kurdin


On 11/2/2011 7:26 AM, hstod wrote:

 

gimana cara edit data pada tabel2 dengan code :

Set db = CurrentDb
Set rs = db.OpenRecordset("table2")
rs.edit
rs("id") = Me![text0]
rs("nama") = Me![text1]
rs("alamat") = Me![text2]
rs("kelas") = Me![text3]

rs.Update
rs.Close

-edit data berdasarkan file yang di munculkan via combobox table2 tsb.
-edit di atas hanya bisa akurat jika hanya 1 record saja, tapi kalau lebih jadi ter edit semuanya

SrchCrit = "[Project_Number] ='" & Me![Project_Number] & "'"
rs.FindFirst SrchCrit

sy coba tambahan kode ini tapi error.., atau kalau cara lain untuk update ke tabel dari form?

tks


__._,_.___
Recent Activity:
SPAM IS PROHIBITED
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar