473,420 Members | 4,459 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,420 software developers and data experts.

Clearing invalid date from a combo box

204 128KB
I have a form with several combo boxes, all with Limit to List on. If a user enters invalid data into one of them, of course he gets the "not in list" message. If he then decides he was on the wrong track and tries to cancel the form (Cancel button click event = Me.Undo), Access still keeps insisting on a valid entry in the combo box. I can't go back and clear it programmatically because the focus is now on the Cancel button and I can't tell which control caused the error or what its previous value was.
Of course it is always possible (in fact, it is necessary) for the user to then delete the erroneous entry or randomly select an acceptable one before cancelling the form, but this is non-intuitive and a bit of a nuisance. Is there any way I can really undo and cancel the form in the Cancel button click event (other than saving all the values of all the controls when the form is opened and then restoring them one by one!)?
Thanks for your help.
Oct 22 '22 #1

✓ answered by zmbd

There is a combobox.notinlist event that you should consider using to reset the control.
(https://learn.microsoft.com/en-us/of...obox.notinlist)
In certain circumstances I use this event in several of my front-ends to add new entries to the allowed list and in others I cancel the entry and reset it to blank.

4 12705
NeoPa
32,556 Expert Mod 16PB
Hi Petrol.

Are you sure that the code for the Cancel_Click() event is even being reached. I would not expect it to get that far if the ComboBox had no valid selection. The way to handle that would be either the simple <ESC> key or, if there's a valid event triggered by an invalid entry (I think there may be.), then put code in there to Undo() the control.

Does that make sense?
Oct 23 '22 #2
zmbd
5,501 Expert Mod 4TB
There is a combobox.notinlist event that you should consider using to reset the control.
(https://learn.microsoft.com/en-us/of...obox.notinlist)
In certain circumstances I use this event in several of my front-ends to add new entries to the allowed list and in others I cancel the entry and reset it to blank.
Oct 23 '22 #3
Petrol
204 128KB
Thank you both; you're both right. I had forgotten there was a NotInList event.
Oct 24 '22 #4
zmbd
5,501 Expert Mod 4TB
Our pleasure
If you run into a snag implementing this please feel free to post back to the thread
=Z
Oct 24 '22 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: GaudaPrime | last post by:
Hi, I have an Oracle 8i instance which has somehow managed to store the 29th of February 2005 in a date field. As 2005 isn't a leap year this is an invalid date. SQL> select NEXTTRIG_DATE,...
0
by: Mike D | last post by:
now and again i've noticed that the Received field in a table linked from an Exchange server will have an invalid date. the invalid date always seems to be some day and some month in the year...
7
by: simonmarkjones | last post by:
Hi, I have a report i would like created based upon a date the user types in. I have a query which in the criteria section of my date field i have put . The report is created fine when a...
3
by: Mage | last post by:
Hi, can pgsql acceppt invalid date values? Sometimes it would be nice to convert 2003-02-29 to 2003-03-01 or to 2003-02-28 automatically instead of throwing back an error message. Mage ...
2
by: gavin | last post by:
Have a Windows for with a textbox. Enter a date 2006/1/1/ -Note an additinal / on th end This is clearly an error but when text is cast to a date the extra / is automatically removed. The cast...
7
by: Pam Poulos | last post by:
I have a form where users input some dates, these dates are then written to date variables. I need to clear out the date variables with either an empty string or a null value. Currently, I am...
2
by: kannan1983 | last post by:
Iam having a column which contains year (e.g 2005,2006), i have to validate each and every value in this column, if it is like(e.g.20005,20600,200060006) i have to caputure this value , for that i...
2
by: Andrew Poulos | last post by:
If I check for a invalid date e.g. February 30th, 2008? Andrew Poulos
3
by: TnTourGuy | last post by:
I am trying to combine a JavaScript that will change a selected text based on a actual date and time of day of that date... Example:: Jan. 6, 2012 @ 8:00am the text would read "Clue #1 - It's...
11
by: dowlingm815 | last post by:
When a date field contains an invalid date, it needs to be flagged. However, my code is not acknowledging it. For instance, it doesn't recognize 8/15/0007 as a bad date. Any assistance would be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.