hi please help me with this. when I try to save it, it saved. but the problem, it is saving though it has the same record

If idno.Text = "" Or proflname.Text = "" Or proffname.Text = "" Or _

              profmi.Text = "" Or subcode.Text = "" Or teachuser.Text = "" Or teachpass.Text = "" Then

          MsgBox("One of the Mandartory field is empty. Please try again", 16, "Message")

       elseif subcode.text=adors.fields("classsec").value then
           msgbox("already exist")

           subcode.text=""
       Else

            adoRS = cn.Execute("INSERT INTO teacherinfo([idno], [proflname], [proffname], [profmi], [classsec], [profusername], [profpassword]) VALUES('" & idno.Text & "', '" & proflname.Text & _
                               "','" & proffname.Text & "','" & profmi.Text & "','" & subcode.Text & "','" & teachuser.Text & "','" & teachpass.Text & "')")
            MsgBox("successfully Registered!", 64, "SAVE")
            idno.Text = ""
            proflname.Text = ""
            proffname.Text = ""
            profmi.Text = ""
            subcode.Text = ""
            teachuser.Text = ""
            teachpass.Text = ""
        End If

If idno.Text = "" Or proflname.Text = "" Or proffname.Text = "" Or _
profmi.Text = "" Or subcode.Text = "" Or teachuser.Text = "" Or teachpass.Text = "" Then

Why did you want with that blank Condition chacking? There is no codes to execute after satisfying these conditions.
If you want to do nothing after satisfying the condition, simply exit from the sub.

If idno.Text = "" Or proflname.Text = "" Or proffname.Text = "" Or _
              profmi.Text = "" Or subcode.Text = "" Or teachuser.Text = "" Or teachpass.Text = "" Then
    Exit Sub          
End If
'.....
'Here first you have to find the
'matching data in the recordset
'.....

'......
'Check a condition if there
'is a duplicate data 
'then exit else add a new data row
'......
'......

Edited 1 Year Ago by Shark_1

Before you attempt to save data you need to firstly check if it do exist or not, checking of data existence is up to you, mean you can check by I'd, Name, etc, check out this solution here.

 itknowledgeexchange.techtarget.com/itanswers/code-to-serch-record-already-exist-or-not/

Hope it answer your question.

This article has been dead for over six months. Start a new discussion instead.