Solved

Masked Edit Control format

Posted on 2000-04-26
7
1,494 Views
Last Modified: 2008-03-03
Hi, can anyone tell me how to set the masked edit control format as short date format in Excel VBA?


I have VB. code as follows:

Private Sub DTPickerActual_Change()

MskEd4.Text = DateAdd("d", -4, DTPickerActual.Value)
MskEd10.Text = DateAdd("d", -10, DTPickerActual.Value)
MskEd30.Text = DateAdd("d", -30, DTPickerActual.Value)
MskEd60.Text = DateAdd("d", -60, DTPickerActual.Value)

End Sub

I can not tell what is wrong with this code.  In the Date/Time picker control property, I set format as 1-dtpShortDate.  And I checked the interval argument in DateAdd Founction, "d" is set as DAY.  But how come I will get both date and time in the masked edit text box?  I also try to put "y"  instead of "d", it remains the same.  Is there any setting I need to take care in the masked edit box properties?  I just want those masked edit boxes display the date not the time.

Thanks

Lisa
0
Comment
Question by:lisaswu
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
antrat earned 100 total points
ID: 2753809
Hi lisaswu

I suspect the problem is that default for the datepicker control value is time and date.
Try using:
MskEd4.Text = Format(DateAdd("d", -4, DTPickerActual.Value),"d/m/yy")
 
Or in the change Event for the MskEd textboxes place some code like this:


If ISDATE(MskEd4)then
 MskEd4=Format(MskEd4,"d/m/y")
End if

you can use any recognised format for the date i.e "m/d/yy", "m-d-yy", "dddd d mmm yyyy" etc



antrat
0
 

Author Comment

by:lisaswu
ID: 2753883
Hi Antrat,

I tried both codes, they did not work.  I got warning like : Can't find project or library, with "Format" highlighted.  

I don't know what's the default value of date time picker. But it doesn't display time but date in my case.

lisaswu

0
 
LVL 9

Expert Comment

by:antrat
ID: 2754193
Hi Lisaswu

If the keyword Format is giving an Error then you will need to install the libary for it. While in the VBE go to Tools>References then search through the "Available references" until you see one which is Pre-Fixed with the word "Missing" select it and you should see the File path in the frame below. then use the browse button to locate and open it. I THINK the file is something like icLabel.??

If you cannot see anything that is Pre-Fixed with "Missing" then run the code again so that you get the Error Message then hit De-bug and try again.


If Excel tells you that the Control or references is in use then delete the "Format" keyword(s) from your code save your file and then try.


You may also want to consider using the Calendar Control instead of Date/Time Picker You should be able to see this control in the "Available references" it's probaly called "Microsoft Calendar Control 8".


Good luck and let me know if you have any probs.

antrat
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:lisaswu
ID: 2770930
Hi Antrat,

Sorry for not replying your comment for so long.  I was out of town last couple few days.

I tried to install the library that were missing.  They were as follows:
Microsoft Active X Data Objects (Multi-dimensional)1.0 Library
Microsoft Active X Data Objects 2.1 library
Microsoft Active X Data Objects Recordsets 2.1 library

I was unable to install the first one, because there's no MSADOMD in my computer. What can I do with that?

By the way, I checked the available reference, there's no "Microsoft Calendar Control 8".

Thank you

Lisaswu
0
 

Author Comment

by:lisaswu
ID: 2770931
Adjusted points from 50 to 100
0
 

Author Comment

by:lisaswu
ID: 2829558
Hi Antrant,

Lately, we just upgraded our computers in the lab. I try your solution again.  It works.  Thank you very much.  And sorry for giving you the points this late.  You deserve it.

Lisa
0
 
LVL 9

Expert Comment

by:antrat
ID: 2830316
Thanks lisaswu

No problem, glad to help anytime :)

antrat
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question