0

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
3
Contributors
2
Replies
13
Views
2 Years
Discussion Span
Last Post by Mr.M
0

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 by Shark_1

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.