CPGDeveloper
Board Regular
- Joined
- Oct 8, 2008
- Messages
- 189
Hi All -- I administer an Application -- Access Front End/Azure SQL Server Back End -- I'm trying to create validation for a bound text field on a form, which is bound to a SMALLINT (32,767 max range) field in our back end.
This field can only be between 0 and 1000. While I could create that validation for the field in the back end, if I do that, as far as I can tell, there is no way to avoid system generated messages if someone enters, say 2000:
"The value you entered isn't valid for this field"
Instead of that, the client wants a polished message, that in this case, says something to the effect of 'You cannot enter a value over 1000'. So if I write some kind of validation in the BeforeUpdate Event:
If txtField1.value>1000 Then
Me.txtField1.Undo
docmd.openform "fErrorMessageForm" 'form with company logo and error message
End If
The Undo function doesn't seem to work here. It simply is not producing the previous value in the field, but odd random values. 'Me.Undo' works, however, it would undo any other changes the user may have made. 'Me.Undo' also works if I use it on the AfterUpdate Event, but Me.txtField1.Undo does nothing. In addition, if I leave this field as purely a SMALLINT and the user enters say '50,000', the system generated 'The value you entered isn't valid for this field' message will pop-up, and this code will not execute.
Is there something I'm missing here? Or perhaps there's a much better way to do this? Thanks in advance for your time and feedback, much appreciated!
This field can only be between 0 and 1000. While I could create that validation for the field in the back end, if I do that, as far as I can tell, there is no way to avoid system generated messages if someone enters, say 2000:
"The value you entered isn't valid for this field"
Instead of that, the client wants a polished message, that in this case, says something to the effect of 'You cannot enter a value over 1000'. So if I write some kind of validation in the BeforeUpdate Event:
If txtField1.value>1000 Then
Me.txtField1.Undo
docmd.openform "fErrorMessageForm" 'form with company logo and error message
End If
The Undo function doesn't seem to work here. It simply is not producing the previous value in the field, but odd random values. 'Me.Undo' works, however, it would undo any other changes the user may have made. 'Me.Undo' also works if I use it on the AfterUpdate Event, but Me.txtField1.Undo does nothing. In addition, if I leave this field as purely a SMALLINT and the user enters say '50,000', the system generated 'The value you entered isn't valid for this field' message will pop-up, and this code will not execute.
Is there something I'm missing here? Or perhaps there's a much better way to do this? Thanks in advance for your time and feedback, much appreciated!