pls help me on my code.. i had successfully avoid data redundant but there is an error
"Item cannot be found in the collection corresponding to the requested name or ordinal." and because of that, i wasn't been able to store new data that wasn't exist in my database.
please help me... heres my code.
* Jefferson Alomia *
** VB 2010 Express Edition **
***** Record Management System for Government Project ****
*
*
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
rs = New ADODB.Recordset
With rs
'check if important item is null '
If txtappln.Text = "" Or txtappfn.Text = "" Or txtappmn.Text = "" Or txtclass.Text = "" Or txtaddr.Text = "" Or txtcnum.Text = "" Or txtbrgy.Text = "" Then
MsgBox("Some object in the Applicant Personal Information or Classification or Ctrl Number is not filled up", MessageBoxIcon.Warning)
.Cancel()
End If
sql = "Select COUNT(*) As numrec from Applicant where CONTROL_NO='" & txtcnum.Text & "'"
'Save'
Debug.WriteLine(sql)
.Open(sql, con, 2, 3)
If rs("numrec").Value = 1 Then
MsgBox("dwadawdwa")
.Close()
Else
.AddNew()
.Fields("LAST_NAME").Value = txtappln.Text
.Fields("FIRST_NAME").Value = txtappfn.Text
.Fields("MIDDLE_NAME").Value = txtappmn.Text
.Fields("ADDRESS").Value = txtaddr.Text
.Fields("CLASSIFICATION").Value = txtclass.Text
.Fields("CONTROL_NO").Value = txtcnum.Text
.Fields("BARANGAY").Value = txtbrgy.Text
MsgBox("Record has been save !!", vbInformation)
.Update()
.Close()
End If
End With
With rs
sql = "Select COUNT(*) As numrec from Spouse where CONTROL_NO='" & txtcnum.Text & "'"
.Open(sql, con, 2, 3)
If txtappln.Text = "" Or txtappfn.Text = "" Or txtappmn.Text = "" Or txtclass.Text = "" Or txtaddr.Text = "" Or txtcnum.Text = "" Or txtbrgy.Text = "" Then
.Cancel()
End If
If rs("numrec").Value = 1 Then
MsgBox("dwadawdwa")
.Close()
Else
.AddNew()
.Fields("LAST_NAME").Value = txtspln.Text
.Fields("FIRST_NAME").Value = txtspfn.Text
.Fields("MIDDLE_NAME").Value = txtspmn.Text
.Fields("BARANGAY").Value = txtbrgy.Text
.Fields("CONTROL_NO").Value = txtcnum.Text
txtappln.Text = ""
txtappfn.Text = ""
txtappmn.Text = ""
txtspln.Text = ""
txtspfn.Text = ""
txtspmn.Text = ""
txtaddr.Text = ""
txtclass.Text = ""
txtcnum.Text = ""
txtbrgy.Text = ""
.Update()
.Close()
End If
End With