2
Private Sub cmdSave_Click() 'to save ammendments made in record If MsgBox("Are you sure you want to save this record?", vbQuestion + vbYesNo) = vbYes Then If txtPatientID.Text = "" Or txtPName.Text = Empty Or txtPSurname.Text = Empty Or txtDateOfBirth.Text = Empty Or txtAdmissionDate.Text = Empty Then MsgBox (" A record cannot contain a blank field! Please check"), vbCritical + vbInformation + vbOKOnly If txtPatientID.Text = "" Then txtPatientID.SetFocus ElseIf txtPName.Text = "" Then txtPName.SetFocus End If Else If Len(txtPatientID.Text) = 4 And (txtPatientID >= "P001" And txtPatientID <= "P999") Then AdoPatients.Recordset.Update MsgBox ("The record has been successfuly updated!"), vbOKOnly Unload Me frmPatients.Show vbModal Else: MsgBox ("Record not valid"), vbApplicationModal + vbCritical frmPatients.txtPatientID.Enabled = True frmPatients.txtPatientID.Text = "" frmPatients.txtPName.Enabled = True frmPatients.txtPName.Text = "" frmPatients.txtPSurname.Enabled = True frmPatients.txtPSurname.Text = ""

VB6.0 Validation and Save All in CmdSave_Click()

Embed Size (px)

DESCRIPTION

VB 6.0 programming

Citation preview

Private Sub cmdSave_Click()'to save ammendments made in record

If MsgBox("Are you sure you want to save this record?", vbQuestion + vbYesNo) = vbYes Then If txtPatientID.Text = "" Or txtPName.Text = Empty Or txtPSurname.Text = Empty Or txtDateOfBirth.Text = Empty Or txtAdmissionDate.Text = Empty Then MsgBox (" A record cannot contain a blank field! Please check"), vbCritical + vbInformation + vbOKOnly If txtPatientID.Text = "" Then txtPatientID.SetFocus ElseIf txtPName.Text = "" Then txtPName.SetFocus End If Else If Len(txtPatientID.Text) = 4 And (txtPatientID >= "P001" And txtPatientID