Hi!
I have a subform with a field called Reason Code, which i want to make mandatory.
I know 2 ways to do so:
The simplest one was to make the field in the table as required. This works perfectly, but the problem is that message box that is displayed when the field is left empty. It says something like " you must fill in Warranty claim details.Reason Code". So it look very unprofessional.
The other way was to use VBA. I found something online which basically used the beforeupdate property of the save button which is on the main form. The problem is that the code can be used for a field on the main form but for the sunform case it doesnt work.
the code was something like this:
Dim strMText As String
Dim strMTitle As String
Dim intMType As Integer
If IsNull(Me.YourControl) Then
strMText = "Please complete the "
If IsNull(Me.YourControl) Then
strMText = "YourControl"
Me.YourControlName.SetFocus
End If
strMTitle = "Missing required information"
intMType = vbOKOnly + vbCancel + vbExclamation
MsgBox strMText, intMType, strMTitle
Else
DoCmd.Close
End If
could you tell me either how to edit this code or another way..
Please Help!
I have a subform with a field called Reason Code, which i want to make mandatory.
I know 2 ways to do so:
The simplest one was to make the field in the table as required. This works perfectly, but the problem is that message box that is displayed when the field is left empty. It says something like " you must fill in Warranty claim details.Reason Code". So it look very unprofessional.
The other way was to use VBA. I found something online which basically used the beforeupdate property of the save button which is on the main form. The problem is that the code can be used for a field on the main form but for the sunform case it doesnt work.
the code was something like this:
Dim strMText As String
Dim strMTitle As String
Dim intMType As Integer
If IsNull(Me.YourControl) Then
strMText = "Please complete the "
If IsNull(Me.YourControl) Then
strMText = "YourControl"
Me.YourControlName.SetFocus
End If
strMTitle = "Missing required information"
intMType = vbOKOnly + vbCancel + vbExclamation
MsgBox strMText, intMType, strMTitle
Else
DoCmd.Close
End If
could you tell me either how to edit this code or another way..
Please Help!