coba simpannya jangan di lostfocus. di keypress aja

Private Sub Text1_keypress( )
if keyascii=13 then

If Text1.Text = "" Then Exit Sub

SCari = "select * from data where No_nota= '" + Trim(Text1.Text) + "'"



If RCari.RecordCount <> 0 Then

     If RCari("no_nota" ) = Text1.Text Then

        MsgBox "Nomor Sudah Dipakai", vbOKOnly, "PERHATIAN"

        Text1.SetFocus
     else
     Set RCari = New ADODB.Recordset
   
RCari.Open SCari, CN, adOpenKeyset, adLockReadOnly

     End If

Exit Sub

End If

RCari.Close

Set RCari = Nothing

end if
End Sub


selamat mencoba

--- Pada Rab, 11/3/09, •SετyΘ• <set...@gmail..com> menulis:

Dari: •SετyΘ• <set...@gmail.com>
Topik: [Programmer-VB] [ASK] Dobel Record
Kepada: indoprog...@yahoogroups.com, Programmer-VB@yahoogroups.com
Tanggal: Rabu, 11 Maret, 2009, 1:30 AM











    
            



Pagi master semua,

saya ada sedikit problem nih, maklum pemula :)

Begini saya mencoba menyimpan data nomor nota, begitu nomor nota
kesimpan, kita masukin lagi nomor nota tesebut,

Supaya nomor nota tersebut tidak dobel, gimana ya caranya. 



Kesalahan yg muncul seperti dibawah.



Run time error \3021'



either BOF or EOF is true, or the current record has been deleted.

request operation requires a current record



Saya mencoba membuat perintah seperti
dibawah, database yg digunakan mysql.



Private Sub Text1_lostfocus( )

If Text1.Text = "" Then Exit Sub

SCari = "select * from data where No_nota= '" + Trim(Text1.Text) + "'"

Set RCari = New ADODB.Recordset

RCari.Open SCari, CN, adOpenKeyset, adLockReadOnly

If RCari.RecordCount <> 0 Then

     If RCari("no_nota" ) = Text1.Text Then

        MsgBox "Nomor Sudah Dipakai", vbOKOnly, "PERHATIAN"

        Text1.SetFocus

     End If

Exit Sub

End If

RCari.Close

Set RCari = Nothing

End Sub





Mohon bantuannya rekan-rekan.

Makasih



SH







 

      

    
    
        
         
        
        








        


        
        


      Coba Yahoo! Messenger 9.0 baru. Lengkap dengan segala yang Anda sukai 
tentang Messenger! http://id.messenger.yahoo..com

Kirim email ke