By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

Unwanted validation on listbox

Expert 100+
P: 1,240
Okay, after I typed all that I figured how fix my problem. I thought I'd go ahead and share this anyway. Maybe it will help somebody someday.


This is driving me crazy. I have a listbox, one column only. The listbox is populated dynamically by changing the rowsource depending on user selections. The user selects field names from a list and the values from a table for that column are grouped and shown in the listbox.

Works great, until I get to Zip Code. Five digit zip codes work fine. But a 5-digit zip code followed by a "-", whether the other 4 digits are present or not, gives me (gave me) a validation error. The message is:

"The value you entered isn't valid for this field. For example, you may have entered text in a numeric field, or a number that is larger than the FieldSize setting permits."

The zip data is stored in a table with a 15-character text definition. I changed the underlying query to wrap CSTR() around the zip selection. Helped a little bit, it now is okay with me selecting a 5-digit zip followed by a "-", but it will not accept the same followed by 4 more digits.

There was not validation on the listbox by property, so I added some. The validation I added is "is not NULL" with a message "Help me, I'm NULL". That message never appears.

The message pops up before any events that I can handle are fired. I've put stops in BeforeUpdate and OnClick to test that. Here is the rowsource property at the time of the problem:
Expand|Select|Wrap|Line Numbers
  1. Select Cstr([Zip]) as [Field_Zip] from TargetSelection_qry where 2=2 GROUP BY  Cstr([Zip])
Oh ... well, "at the time of the problem" got me to thinking and now I solved my problem. The initial RowSource property setting was selecting a numeric value. I changed that so when the form opens that listbox is querying a text value column. Now my zip code problem went away. I'll have to start over testing the other fields, though. Who knows what else is behind this curtain.

Thanks for listening.

Jun 14 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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