Hi experts, I have an update form, even without changes made in fields the form will still be updated. How can I code that the form will not update without changes made. Pls help me. Thanks alot.
below is my code.
Private Sub cmdUpdate_Click() If Trim(txtLastname.Text) = "" Or Trim(txtFirstname.Text) = "" Or Trim(txtMiddle_Initial.Text) = "" Or Trim(txtAddress.Text) = "" Or Trim(txtContact_No.Text) = "" Or Trim(txtTin_No.Text) = "" Or Trim(txtSSS_No.Text) = "" Or Trim(txtPhilhealth_No.Text) = "" Or Trim(txtPagibig_No.Text) = "" Or (Option1.Value = False And Option2.Value = False) Then MsgBox "One or more fields is empty.", vbInformation, "Employees" Exit Sub End If Set rs = New ADODB.Recordset rs.Open "select*from Employees where Employees_IdNo='" + Trim(txtID.Text) + "'", cn, adOpenKeyset, adLockPessimistic rs!Employees_IdNo = txtID.Text rs!Lastname = txtLastname.Text rs!Firstname = txtFirstname.Text rs!Middle_Initial = txtMiddle_Initial.Text rs!Address = txtAddress.Text rs!Gender = cboGender.Text rs!Birthdate = DTPickerBirthdate rs!Date_Hired = DTPickerDateHired rs!Rate = lblRate.Caption rs!Civil_Status = cboCivil_Status.Text rs!SSS_No = txtSSS_No.Text rs!Philhealth_No = txtPhilhealth_No.Text rs!Pagibig_No = txtPagibig_No.Text rs!Tin_No = txtTin_No.Text rs!Contact_No = txtContact_No.Text rs!Remarks = txtRemarks.Text If Option1.Value = True Then Option1.Caption = "Female" rs!Gender = "Female" ElseIf Option2.Value = True Then Option2.Caption = "Male" rs!Gender = "Male" End If rs.Update rs.Close Set rs = Nothing MsgBox "Updated!", vbInformation, "Employee" Ado.Refresh End Sub
Edited 3 Years Ago by kimangel