If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Prompt msge re input to mandatory field
I have a handful of mandatory fields on an input form and every now and then
a user will overlook one or another of them. The resulting error message is (a) non-specific and (b) later than it should be. (a) All it says is "The value you entered is not valid for this field. For example, you may have entered text in a numeric field or a number that is larger than the Field Size setting permits". It doesn't refer to any particular field, the cursor isn't flashing in the problem area, the user has to work out where the problem may be. Is it possible to re-word this error msge text or in some other way, tell the user where the problem lies? (b) The message is displayed only when you try to save the record. It would be far better if it was fired as soon as you tried to leave the particular field. I assume this would require some sort of code in an event such as On Update, Lost Focus, or similar... I would appreciate any tips on either/both the above points that would help me make this rather more user-friendly. Thanks a lot CW |
#2
|
|||
|
|||
Prompt msge re input to mandatory field
You cannot just use the events of the control, because there is no guarantee
the user will ever visit the control. Instead, use the BeforeUpdate event of the form. This fires before any engine-level messages, so you can code whatever message you want. Here's an example of how to check several controls, build up a message, and park the cursor in the last one you referred to: Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String Dim strField As String If IsNull(Me.Field1) Then Cancel = True strMsg = strMsg & "Field1 is required." & vbCrLf strField = "Field1" End If If IsNull(Me.Field2) Then Cancel = True strMsg = strMsg & "Field2 is required." & vbCrLf strField = "Field2" End If 'etc for other fields If Cancel Then strMsg = strMsg & vbCrLf & "Correct the entry, or press Esc to undo." MsgBox strMsg, vbExclamation, "Invalid data" Me(strField).SetFocus End If End Sub -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "CW" wrote in message ... I have a handful of mandatory fields on an input form and every now and then a user will overlook one or another of them. The resulting error message is (a) non-specific and (b) later than it should be. (a) All it says is "The value you entered is not valid for this field. For example, you may have entered text in a numeric field or a number that is larger than the Field Size setting permits". It doesn't refer to any particular field, the cursor isn't flashing in the problem area, the user has to work out where the problem may be. Is it possible to re-word this error msge text or in some other way, tell the user where the problem lies? (b) The message is displayed only when you try to save the record. It would be far better if it was fired as soon as you tried to leave the particular field. I assume this would require some sort of code in an event such as On Update, Lost Focus, or similar... I would appreciate any tips on either/both the above points that would help me make this rather more user-friendly. Thanks a lot CW |
#3
|
|||
|
|||
Prompt msge re input to mandatory field
Allen -
That looks great, I'll give it a try. Many thanks for your (as always) clear and complete advice. CW "Allen Browne" wrote: You cannot just use the events of the control, because there is no guarantee the user will ever visit the control. Instead, use the BeforeUpdate event of the form. This fires before any engine-level messages, so you can code whatever message you want. Here's an example of how to check several controls, build up a message, and park the cursor in the last one you referred to: Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String Dim strField As String If IsNull(Me.Field1) Then Cancel = True strMsg = strMsg & "Field1 is required." & vbCrLf strField = "Field1" End If If IsNull(Me.Field2) Then Cancel = True strMsg = strMsg & "Field2 is required." & vbCrLf strField = "Field2" End If 'etc for other fields If Cancel Then strMsg = strMsg & vbCrLf & "Correct the entry, or press Esc to undo." MsgBox strMsg, vbExclamation, "Invalid data" Me(strField).SetFocus End If End Sub -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "CW" wrote in message ... I have a handful of mandatory fields on an input form and every now and then a user will overlook one or another of them. The resulting error message is (a) non-specific and (b) later than it should be. (a) All it says is "The value you entered is not valid for this field. For example, you may have entered text in a numeric field or a number that is larger than the Field Size setting permits". It doesn't refer to any particular field, the cursor isn't flashing in the problem area, the user has to work out where the problem may be. Is it possible to re-word this error msge text or in some other way, tell the user where the problem lies? (b) The message is displayed only when you try to save the record. It would be far better if it was fired as soon as you tried to leave the particular field. I assume this would require some sort of code in an event such as On Update, Lost Focus, or similar... I would appreciate any tips on either/both the above points that would help me make this rather more user-friendly. Thanks a lot CW |
Thread Tools | |
Display Modes | |
|
|