Solved

Masked Edit Control format

Posted on 2000-04-26
7
1,490 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Display multiple images in report 12 119
Info Path 2013 with Office 2016 Pro Plus and Standard 2016 1 56
Create Form using Wizard 14 45
VBA name newly created sheet 4 24
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

831 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