Hi
I have a form which is used to enter car parts, the form has a Save button and the X at the top right hand corner. I have the following code in place to make sure the user enters the required fields.
I have a number of problems with this though:
1) If the user moves the wheel on the mouse, it tries to move to a new record and gives validation error.
Is there any way to remove the ability of mouse scrolling?
2) If the user presses the X in the top corner, it gives the validation error message and also shows the "You can't save this record at this time" error message.
Is there a way of changing that error message and upon the user clicking "yes" cancelling the data and closing the form?
I have searched for a solution but come up with nothing.
I have a form which is used to enter car parts, the form has a Save button and the X at the top right hand corner. I have the following code in place to make sure the user enters the required fields.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim msg As String, Style As Integer, Title As String
Dim nl As String, ctl As Control, Source As String
nl = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "*" And Trim(ctl & "") = "" Then
msg = "Data Required for '" & ctl.Controls(0).Caption & "' field" & nl & _
"You can't save this record until this data is provided" & nl & _
"Enter the data and try again . . . "
Style = vbCritical + vbOKOnly
Title = "Required Data..."
MsgBox msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
End Sub
I have a number of problems with this though:
1) If the user moves the wheel on the mouse, it tries to move to a new record and gives validation error.
Is there any way to remove the ability of mouse scrolling?
2) If the user presses the X in the top corner, it gives the validation error message and also shows the "You can't save this record at this time" error message.
Is there a way of changing that error message and upon the user clicking "yes" cancelling the data and closing the form?
I have searched for a solution but come up with nothing.