?
Solved

Masked Edit Control format

Posted on 2000-04-26
7
Medium Priority
?
1,523 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
antrat earned 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

764 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