code entry as a date

G

Guest

Hi, I have learned from here to use a code entry as a date. It works out
great and fast for the users to input the date on a form. I have set up for
a maximum of 8 days (8 keys), however some users may be out for a long
vacation, the date-field will be input manually. I don't know how to make
this field for both possiblities, i.e. it can be input through a key or
manually input the date.

Because of the following setting, the users can't input the date manually in
the field.
Please help what should I add the "extra" :

Private Sub MyField_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 '0
KeyAscii = 0
Screen.ActiveControl = Date

Case 49 '1
KeyAscii = 0
Screen.ActiveControl = Date - 1

End Select

I have set up up to the Case 55 for Date - 6, etc.
Please help to add an extra possibility to allow a manual date input in
MyField.

thanks
Karen
 
G

Guest

My code was much the same as your code. I added more Case statements to
handle pressing the + or - keys, w to add or subtract a week, m to add or
subtract a month, y to add or subtract a year, t for ten days,...

I didn't want to repeat this same code for every date text box on every
form, so I added the function to a standard module and call it from the
KeyPress event of the control. Each control has the same one line of code
rather than a ton of code for each control.
 
G

Guest

Thanks for your answer.
I am sorry this is far beyond my understanding. I will keey this in my
file and try it out. At this moment, I have to use a very simple one.

thanks again
karen
 
G

Guest

I sure will try, Douane, thanks for the kind thoughts.

It's because I am out for vacation next week, I haven't got enough time to
test out for it. It's my own fault, running out of time. As I said, I have
already saved it in my file and from what you explained, it should be good.

Again, thanks for your help,
Karen
 
G

Guest

I see. thanks for explaining. I am sure yours is a very good programming
stuff, it's just my problem that I am not good in the module, I couldn't
figure out how to handle that.
I am sure I will try this out.
Karen
 
G

Guest

Try to add more Case statements to handle other key press values. Try add and
test one at a time. If you have questions, come on back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top