Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Access Newsgroups
Access Forms
Problem with Validation Error
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Rob Parker, post: 1696646"] Daryl, Thanks for the advice on setting index properties - it's not something that I've ever done; I normally simply set the Indexed property to one of the options available on the General tab of the table's property sheet. However, changing this to Ignore Nulls has no effect. Setting a breakpoint shows that the message is triggered when the Sub ends (ie. after the End Sub statement, which is immediately after the End If statement). Checking the table after entering a valid CAR number in the textbox confirms that the record is not added at this time. I'm completely puzzled as to why the validation message is occurring when the record should not be being saved. In desperation, thinking that maybe the textbox had previously had a validation rule applied to it in a previous life (it's likely to be a copy of a copy of a copy ..., since I often generate new forms from something similar (perhaps even in a different database) and simply change names and recordsources), I deleted the textbox and added a new one (directly form the toolbox, giving it a different name) which I then bound to the CARNumber field. I entered the same code for this new control - which certainly has never had any validation associated with it - and found exactly the same behaviour. I've now implemented a work-around, as follows: Dim ValidData as Boolean 'Set module-level variable Private Function ValidData() As Boolean ValidData = True If Not (Text27 Like "C####") Then ValidData = False MsgBox "Error" Text27.SetFocus End If End Function And finally, in the form's cmdAddCAR button (the only way out which saves the record - there's also a Cancel button which has Me.Undo and then closes the form): Private Sub cmdAddCAR_Click() If ValidData Then DoCmd.Close acForm, "frmAddCAR" End Sub This code works as I expect - no validation message occurs. But I'm still deeply puzzled. Rob [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Access Newsgroups
Access Forms
Problem with Validation Error
Top