Hi All,
I am new on this forum and would please like some help with two aspects of a User Form that I am currently working on.
I am having problems coming up with the correct VBA codes for the ‘DATE’ text box and the ‘DESCRIPTION’ text box, to do what I wish to achieve. I am a newbie in VBA, and I am happy to learn more with the kind help of members of this forum.
1. The 'DATE' text box
The Date textbox requires users to key in the date of transaction. This and other entries on the userform are transferred to a database.
The vba code that I inserted is to ensure that if a user types in a date in any form, the date will automatically convert to ‘dd/mm/yyyy’. For example, for the date 13/04/2013 – if a user keys in either 13.4.13 (with foolstops), or 13 4 13 (with spaces), or 13/4/13 (with forward slashes), and presses the tab key, the date immediately converts to 13/04/2013.
However, I have observed a problem: if, in error, someone keys into the date box, say, 113.4.13 (with foolstops), or 113 4 13 (with spaces), the code converts the date to 13/04/0113. This result is not a date, and I can’t figure out how to solve this problem.
I have appended below all the date-related codes that I use in the userform. I should be grateful if someone could, please, adjust the code for me, so that I don’t have that problem.
2.The ‘DESCRIPTION’ text box
For the ‘Description’ textbox, I used the ‘If IsNumeric …’ code to ensure that the box does not contain only NUMBERS. It should contain text or a combination of text and numbers – but never only numbers.
However, using the code below, I find that if, for example, I type into the Description box, say, 122345, I get a warning message - which is OK. However, if there is a space splitting the number into two, for example 12 2345, the code accepts it and would transfer it to the database even though it is all numbers and I don't want that to happen. I have appended below the code that I use for this, and should also be grateful for help to adjust the code so as to prevent this.
Thank you all in anticipation of your kind help.
newqueen
Bookmarks