|
-
Feb 13th, 2004, 05:32 PM
#1
Thread Starter
Lively Member
coding prob
my system will do this operations -->
add new, save, edit and delete data.
my prob is everytime i want to save data, this error msg appears which is
"either BOF or EOF, or the current record has been deleted, requested operation requires a current record"
im new in vb programming.
i cant figure out whts the meaning of the error.
anyone here can help me??
tq in advance
VB Code:
Private Sub tbrPekerja_ButtonClick(ByVal Button As MSComctlLib.Button)
Set conn = GetConnection
Set rs = New ADODB.Recordset
'rs.Open "SELECT * FROM pekerja WHERE id_pekerja = '" & txtSearch.Text & "'", conn, adOpenStatic, adLockOptimistic
Select Case Button.index
'add new record
Case Is = 5
txtID.Locked = False
txtNamaPekerja.Locked = False
txtNoIC.Locked = False
txtAlamatPekerja.Locked = False
txtNoTel.Locked = False
txtSearch.Text = ""
txtID.Text = ""
txtNamaPekerja.Text = ""
txtNoIC.Text = ""
txtAlamatPekerja.Text = ""
txtNoTel.Text = ""
tbrPekerja.Buttons.Item(6).Enabled = True
txtID.SetFocus
rs.AddNew
'save data
Case Is = 6
'Set Conn = GetConnection
'[b]error[/b]
rs!id_pekerja = UCase(txtID.Text)
rs!nama = txtNamaPekerja.Text
rs!ic = txtNoIC.Text
rs!alamat = txtAlamatPekerja.Text
rs!telefon = txtNoTel.Text
rs.Update
MsgBox "Data telah di simpan", vbInformation, "Simpan Data"
tbrPekerja.Buttons.Item(6).Enabled = False
txtID.Locked = True
txtNamaPekerja.Locked = True
txtNoIC.Locked = True
txtAlamatPekerja.Locked = True
txtNoTel.Locked = True
'edit data
Case Is = 7
txtSearch.Locked = False
txtID.Locked = False
txtNamaPekerja.Locked = False
txtNoIC.Locked = False
txtAlamatPekerja.Locked = False
txtNoTel.Locked = False
tbrPekerja.Buttons.Item(6).Enabled = True
'delete data
Case Is = 8
If MsgBox("Adakah anda pasti?", vbQuestion + vbYesNo) = vbYes Then
rs.Delete
MsgBox "Data telah dihapus", vbOKOnly, "Hapus Data"
txtSearch = ""
txtID = ""
txtNamaPekerja = ""
txtNoIC = ""
txtAlamatPekerja = ""
txtNoTel = ""
End If
rs.Close
Set rs = Nothing
End Select
end sub
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
|