Private Sub btnSave_Click()
'If MsgBox("Do you want to SAVE the record (or the change)", vbYesNo, "Save Record...") = vbNo Then
' Me.Firstname.SetFocus
' Me.Company.SetFocus
' Me.Undo
' Cancel = True
' Validates that Control has Data for required feilds
If Len(Firstname) = 0 Or IsNull(Firstname) = True Then
Call MsgBox("You must enter First Name", vbExclamation, "Add Firstname")
Me.Company.SetFocus
Me.Firstname.SetFocus
Cancel = True
ElseIf Len(Lastname) = 0 Or IsNull(Lastname) = True Then
Call MsgBox("You must enter Last Name", vbExclamation, "Add Lastname")
Me.Company.SetFocus
Me.Lastname.SetFocus
Cancel = True
ElseIf Len(Address1) = 0 Or IsNull(Address1) = True Then
Call MsgBox("You must enter Address1", vbExclamation, "Add Address1")
Me.Company.SetFocus
Me.Address1.SetFocus
Cancel = True
ElseIf Len(City) = 0 Or IsNull(City) = True Then
Call MsgBox("You must enter City", vbExclamation, "Add City")
Me.Company.SetFocus
Me.City.SetFocus
Cancel = True
ElseIf Len(State) = 0 Or IsNull(State) = True Then
Call MsgBox("You must select a State", vbExclamation, "Add State")
Me.Company.SetFocus
Me.cboState.SetFocus
Cancel = True
ElseIf Len(Zip) = 0 Or IsNull(Zip) = True Then
Call MsgBox("You must enter a Zip", vbExclamation, "Add Zip")
Me.Company.SetFocus
Me.Zip.SetFocus
Cancel = True
ElseIf Len(Phone) = 0 Or IsNull(Phone) = True Then
Call MsgBox("You must enter a Phone No", vbExclamation, "Add Phone")
Me.Company.SetFocus
Me.Phone.SetFocus
Cancel = True
ElseIf Len(cboCSR) = 0 Or IsNull(cboCSR) = True Then
Call MsgBox("You must select a CSR", vbExclamation, "Add CSR")
Me.Company.SetFocus
Me.cboCSR.SetFocus
Cancel = True
ElseIf Len(cboMod) = 0 Or IsNull(cboMod) = True Then
Call MsgBox("You must select a Model", vbExclamation, "Add Model")
Me.Company.SetFocus
Me.cboMod.SetFocus
Cancel = True
ElseIf Len(Serial) = 0 Or IsNull(Serial) = True Then
Call MsgBox("You must select a Serial Number", vbExclamation, "Add Serial")
Me.Company.SetFocus
Me.Serial.SetFocus
ElseIf Len(ProblemDesc) = 0 Or IsNull(ProblemDesc) = True Then
Call MsgBox("You must select a Problem Description", vbExclamation, "Add ProblemDesc")
Me.Company.SetFocus
Me.ProblemDesc.SetFocus
'Save the record.
RunCommand acCmdSaveRecord
'Load a new record after the save.
DoCmd.GoToRecord , , acNewRec
End If
'End If
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE