Code:
Dim rs1 As New ADODB.Recordset
Private Sub cmdadd_Click()
Adodc1.Refresh
End Sub
Private Sub cmdcancle_Click()
If MsgBox("Are you sure you don't want to save the record ?", 4 + 32, Title) = vbNo Then
GoTo EXITPROCEDURE
Else
Unload Me
mainfom.Show
End If
EXITPROCEDURE:
Exit Sub
End Sub
Private Sub cmdgotomainform_Click()
If MsgBox("Are you sure you want to GoTo Home ?", 4 + 32, Title) = vbNo Then
GoTo EXITPROCEDURE
Else
mainfom.Show
Unload Me
End If
EXITPROCEDURE:
Exit Sub
End Sub
Private Sub cmdsave_click()
If txtcustomername.Text = "" Then
MsgBox "Please Enter Customer Name", vbExclamation, Title
txtcustomername.SetFocus
Exit Sub
End If
If txtdateofbirth.Text = Date Then
MsgBox "Date of Birthday Cannot be today, Please Change it", vbExclamation, Title
dateofbirth.SetFocus
Exit Sub
End If
If comboselectgender.Text = "-Select Gender-" Or comboselectgender.Text = "" Then
MsgBox "Please Select a Gender", vbExclamation, Title
comboselectgender.SetFocus
Exit Sub
End If
If txtaddress.Text = "" Then
MsgBox "Please Enter the Address", vbExclamation, Title
txtaddress.SetFocus
Exit Sub
End If
If txtphone.Text = "" Then
MsgBox "Please Enter Phone/Mobile Number", vbExclamation, Title
txtphone.SetFocus
Exit Sub
End If
If txtemail.Text = "" Then
MsgBox "Please Enter E-Mail", vbExclamation, Title
txtemail.SetFocus
Exit Sub
End If
Adodc1.Recordset.AddNew
MsgBox "Record Sucessfully Added"
End Sub
Private Sub dateofbirth_Change()
txtdateofbirth = dateofbirth.Value
End Sub
Private Sub txtaddress_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtaddress.Text <> "" Then
txtphone.SetFocus
End If
End Sub
Private Sub txtcustomername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtcustomername.Text <> "" Then
dateofbirth.SetFocus
ElseIf (KeyAscii < 65 And KeyAscii <> 8 And KeyAscii <> 32) Or (KeyAscii > 90 And KeyAscii < 97) Or (KeyAscii > 122) Then
KeyAscii = 0
MsgBox "Enter Letters Only!!"
End If
End Sub
Private Sub txtemail_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtemail.Text <> "" Then
cmdsave.SetFocus
End If
End Sub
Private Sub txtphone_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtphone.Text <> "" Then
txtemail.SetFocus
ElseIf (KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57 Then
KeyAscii = 0
MsgBox "Enter Digits Only!!"
End If
End Sub
Private Sub Form_Load()
txtcustomerid.Text = ""
txtcustomername.Text = ""
txtdateofbirth.Text = ""
comboselectgender.Text = ""
txtaddress.Text = ""
txtphone.Text = ""
txtemail.Text = ""
End Sub