How can I make my program prompt a warning message box saying that the data already exist?. For example if I enter the same employee Id a message box will prompt saying the id already exist. And where should i put the code.
Here is my code for the save button
Here is my code for the save button
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Call disControl()
'Validation
If invalidSaveEntry() = True Then
Call enaControl()
Exit Sub
End If
If MsgBox("Are you sure you want to save this record?", CType(MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question, MsgBoxStyle), "Save") = MsgBoxResult.Yes Then
'Start Save
SQL = "Insert into tbl_info(fldid," & _
"fldname," & _
"fldate," & _
"fldateemployed," & _
"fldposition," & _
"fldepartment," & _
"fldage," & _
"fldsex," & _
"fldweight," & _
"fldcitizenship," & _
"fldateofbirth," & _
"fldplaceofbirth," & _
"fldcivilstatus," & _
"fldreligion," & _
"fldtelnumber," & _
"fldrplace," & _
"fldpplace," & _
"fldsssnumber," & _
"fldtinnumber," & _
"fldphnumber," & _
"fldpibignumber," & _
"fldelementary," & _
"fldfromto1," & _
"fldhighSchool," & _
"fldfromto2," & _
"fldcollege," & _
"fldfromto3," & _
"fldfthname," & _
"fldfage," & _
"fldfoccupation," & _
"fldmthname," & _
"fldmage," & _
"fldmoccupation," & _
"fldsname," & _
"fldsage," & _
"fldsoccupation," & _
"fldwefromto1," & _
"fldweposition1," & _
"fldweadd1," & _
"fldwesalary1," & _
"fldwefromto2," & _
"fldweposition2," & _
"fldweadd2," & _
"fldwesalary2," & _
"fldwefromto3," & _
"fldweposition3," & _
"fldweadd3," & _
"fldwesalary3," & _
"fldwefromto4," & _
"fldweposition4," & _
"fldweadd4," & _
"fldwesalary4," & _
"fldnename," & _
"fldnerelationship," & _
"fldneadd," & _
"fldnetel," & _
"photo) values('" & Me.txtID.Text.Trim & "'," & _
"'" & Me.txtFname.Text.Trim & "'," & _
"'" & Me.dtpdate.Text.Trim & "'," & _
"'" & Me.dtpdateemployed.Text.Trim & "'," & _
"'" & Me.txtposition.Text.Trim & "'," & _
"'" & Me.CbDepartment.Text.Trim & "'," & _
"'" & Me.txtAge.Text.Trim & "'," & _
"'" & Me.CbSex.Text.Trim & "'," & _
"'" & Me.TxtWeight.Text.Trim & "'," & _
"'" & Me.TxtCitizenship.Text.Trim & "'," & _
"'" & Me.DtDateofBirth.Text.Trim & "'," & _
"'" & Me.TxtPlaceofBirth.Text.Trim & "'," & _
"'" & Me.TxtCStatus.Text.Trim & "'," & _
"'" & Me.TxtReligion.Text.Trim & "'," & _
"'" & Me.TxtTelNo.Text.Trim & "'," & _
"'" & Me.TxtResidenceAddress.Text.Trim & "'," & _
"'" & Me.TxtProvincialAddress.Text.Trim & "'," & _
"'" & Me.TxtSSSNo.Text.Trim & "'," & _
"'" & Me.TxtTIN.Text.Trim & "'," & _
"'" & Me.TxtPhilhealthNo.Text.Trim & "'," & _
"'" & Me.TxtPagibig.Text.Trim & "'," & _
"'" & Me.TxtElementary.Text.Trim & "'," & _
"'" & Me.TxtFromTo1.Text.Trim & "'," & _
"'" & Me.TxtHighSchool.Text.Trim & "'," & _
"'" & Me.TxtFromTo2.Text.Trim & "'," & _
"'" & Me.TxtCollege.Text.Trim & "'," & _
"'" & Me.TxtFromTo3.Text.Trim & "'," & _
"'" & Me.TxtFthname.Text.Trim & "'," & _
"'" & Me.TxtFAge.Text.Trim & "'," & _
"'" & Me.TxtFOccupation.Text.Trim & "'," & _
"'" & Me.TxtMthname.Text.Trim & "'," & _
"'" & Me.TxtMAge.Text.Trim & "'," & _
"'" & Me.TxtMOccupation.Text.Trim & "'," & _
"'" & Me.TxtSName.Text.Trim & "'," & _
"'" & Me.TxtSAge.Text.Trim & "'," & _
"'" & Me.TxtSOccupation.Text.Trim & "'," & _
"'" & Me.TxtWE_Fromto1.Text.Trim & "'," & _
"'" & Me.TxtWE_Position1.Text.Trim & "'," & _
"'" & Me.TxtWE_Add1.Text.Trim & "'," & _
"'" & Me.TxtWE_Salary1.Text.Trim & "'," & _
"'" & Me.TxtWE_Fromto2.Text.Trim & "'," & _
"'" & Me.TxtWE_Position2.Text.Trim & "'," & _
"'" & Me.TxtWE_Add2.Text.Trim & "'," & _
"'" & Me.TxtWE_Salary2.Text.Trim & "'," & _
"'" & Me.TxtWE_Fromto3.Text.Trim & "'," & _
"'" & Me.TxtWE_Position3.Text.Trim & "'," & _
"'" & Me.TxtWE_Add3.Text.Trim & "'," & _
"'" & Me.TxtWE_Salary3.Text.Trim & "'," & _
"'" & Me.TxtWE_Fromto4.Text.Trim & "'," & _
"'" & Me.TxtWE_Position4.Text.Trim & "'," & _
"'" & Me.TxtWE_Add4.Text.Trim & "'," & _
"'" & Me.TxtWE_Salary4.Text.Trim & "'," & _
"'" & Me.TxtNE_Name.Text.Trim & "'," & _
"'" & Me.TxtNE_Relationship.Text.Trim & "'," & _
"'" & Me.TxtNE_Add.Text.Trim & "'," & _
"'" & Me.TxtNE_Tel.Text.Trim & "'," & _
"'" & Me.PictureBox1.Image.PixelFormat & "')"
Call execComDB(SQL) 'Execute the insert query
Me.Close() 'Close the form
'*** Display new record
SQL = "Select * from tbl_info " & _
"order by fldid desc"
Call frmMain.dispRec(SQL)
Call frmMain.dispRecCount() 'Display record count
'--- End of displaying new record
End If
End Sub