Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Month and Year Only 1

Status
Not open for further replies.

bxgti4x4

Technical User
Feb 22, 2002
167
GB
I have a table with a date field which is formatted "mmmm yyyy" which shows me "December 2004" if I type in "1/12/04".

I would like to be able to type in only "12/04" and get the same result but I cannot find a format that will enable me to do it.

Any help would be much appreciated

Best Regards
John

 
field properties of table:
format: mmmm yyyy
input musk: 00/0000;0;#

Regards Greek Patriot from Cyprus.
 
I put the input mask in as you suggested but when I entered "11/04" it returned an error box which said that the value I entered was not appropriate for the input mask specified for this field.

John
 
HMM i TRIED IT OK THERE IS A MISTAKE. WHEN YOU CHOOSE A DATE/???? THE LEAST INPUT YOU CAN INSERT IS THIS ##/##/##

So I will correct the input mask to: 00/00;0;#
00/00/00;0;#

This works not sure that this is what you wanted.
 
Yes, I think I agree that it will not recognise just a month and a year - you must put in a day as well. If I do that without an input mask it works, I just wondered if there was a way of making it accept just month and year without the day.

Thanks for taking a look.

Best regards
John
 
MAYBE IS BECAUSE YOUR MONTHS AND DAYS ARE REVERSED.
For example mm/dd/yy
dd/mm/yy

Good luck. Sorry for not finding a solution. I am 99% sure that it does not exist.
 
And what about this input mask ?
"01"/00/00;0;_

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
What PHV suggested is what you requested.
Mine works with the following alterations.
00/"01"/00;0;_
Cheers
 
PHV

Thanks for the suggestion it solved the problem.

Greek Patriot

I can see where you were coming from, my date works on a dd/mm/yy format whereas yours was working on mm/dd/yy.

One last question - when I go to enter the month and year, the cursor is over the "1" of "01" and I have to cursor right to get to the first entry (mm). Is there any way that the cursor can be positioned in the blank "mm" part?

Best Regards
John
 
Hi bxgti4x4

If you are using a textbox to enter the value you can use the SelStart property to tell the cursor which position to appear in when the control gets the focus. I don't know how to do it when typing directly into the table though

All the best

Geraint Evans
 
Geraint,

Thanks for the helpful hint. I am entering the data via a text box named "LastDryDock(Date)" on a form and have set the input mask in the form properties i.e "01"/00/00;0;_ so I reckon the cursor should move to the third character. However, I'm having trouble getting the code correct for the SelStart property and would appreciate your help.

Best regards
John
 
No problem

Place this code in the GotFocus event of the textbox:

Code:
LastDryDock(Date).SelStart = 3

you can also use the SelLength property of the text box to tell the control how many characters should be highlighted
e.g. if your SelStart is 3 and SelLength is 2, the cursor would be in front of the months and the next 2 characters would be highlighted

All the best

Geraint
 
Geraint,

Tried that but every time I try to select the control I receive a warning box saying "Run-Time Error 424 Object Required". Any ideas?

Best Regards
John
 
Use brackets:
[LastDryDock(Date)].SelStart

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV
Thanks, that did the trick. Its now working just as I wanted.

Best Regards
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top