Hi guys
I'm trying to force the user to enter the Customername, Contact person and (tel or cell nbr). Everything's fine for the customer and contact person as i hav made the required fields on the table.
The problem is i the user doesn't enter the customername or contact person it complains but closes the screen and i don't want the application to do dat. I want it to complain then go back to the field that still needs to be entered.
I also need help with enforcing data in the tell or cell nbr field (i can't make dem required as it's fine not 2 hav 1 if the other is there)
Here's ma code
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Before closing this form you have to check if the mandotory fields (*) have been entered else complain and don't allow the user to continue
If ValidateRecord = False Then
MsgBox ("Please enter the Customer Name or Contatct")
Me.CustomerName.SetFocus
On Error GoTo Err_cmdMainScreen_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "New_Customer"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdMainScreen_Click:
Exit Sub
Err_cmdMainScreen_Click:
MsgBox Err.Description
Resume Exit_cmdMainScreen_Click
Else
MsgBox ("Done")
End If
End Sub
Ma field types are text by d way.
Thanks
I'm trying to force the user to enter the Customername, Contact person and (tel or cell nbr). Everything's fine for the customer and contact person as i hav made the required fields on the table.
The problem is i the user doesn't enter the customername or contact person it complains but closes the screen and i don't want the application to do dat. I want it to complain then go back to the field that still needs to be entered.
I also need help with enforcing data in the tell or cell nbr field (i can't make dem required as it's fine not 2 hav 1 if the other is there)
Here's ma code
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Before closing this form you have to check if the mandotory fields (*) have been entered else complain and don't allow the user to continue
If ValidateRecord = False Then
MsgBox ("Please enter the Customer Name or Contatct")
Me.CustomerName.SetFocus
On Error GoTo Err_cmdMainScreen_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "New_Customer"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdMainScreen_Click:
Exit Sub
Err_cmdMainScreen_Click:
MsgBox Err.Description
Resume Exit_cmdMainScreen_Click
Else
MsgBox ("Done")
End If
End Sub
Ma field types are text by d way.
Thanks