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
Solved

set the date controls backcolor

Posted on 2000-05-16
4
190 Views
Last Modified: 2010-05-02
Hi,

This is going to sound trivial, but it is an absolute requirement for a major project I work on to be able to set the background colour of the text portion of an MS Date control (from the Microsoft Windows Common Controls 6.0 3 group).

The control only supports the calendarbackcolor - which doesn't affect the background colour of the text portion.

How can I get around this ??
0
Comment
Question by:troywillmot
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2815751
you may consider placing a textbox over the text portion of the control since it supports the backcolor and have the value of the date control be reflected in the textbox.  for example,

Private Sub DTPicker1_Change()
    Text1.Text = DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year
End Sub

Private Sub Form_Load()
    Text1.Text = DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year
End Sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2815754
on the same token you can use the masked edit control since that way you can format it the same as the date control which would allow the flexibility to let the user directly edit the text w/o needing a whole lot of extra code.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2815852
heres an idea using the Microsoft Masked Edit Control:

Option Explicit


Private Sub DTPicker1_Change()
    If DTPicker1.Month > 9 Then
        MaskEdBox1.Mask = "##/##/####"
    Else
        MaskEdBox1.Mask = "#/##/####"
    End If
    MaskEdBox1.Text = CStr(DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year)
End Sub

Private Sub Form_Load()
    With MaskEdBox1
        .Top = DTPicker1.Top
        .Left = DTPicker1.Width
        .Height = DTPicker1.Height
        .Width = DTPicker1.Width - 260
        .Left = DTPicker1.Left
        .BackColor = &H8080FF
    End With
    DTPicker1.Format = dtpCustom
    DTPicker1.CustomFormat = "dd/mm/yyyy"
    If DTPicker1.Month > 9 Then
        MaskEdBox1.Mask = "##/##/####"
    Else
        MaskEdBox1.Mask = "#/##/####"
    End If
    MaskEdBox1.Text = CStr(DTPicker1.Month & "/" & DTPicker1.Day & "/" & _
        DTPicker1.Year)
End Sub
0
 
LVL 3

Author Comment

by:troywillmot
ID: 2815918
Thanks !

Thats the best answer I've had from anybody. I feel stupid for not having thought of it.

I'll build an activeX control that auto-hides/shows the text box when the control gets/looses focus, that way the date control can remain responsible for entering the value - but when the user isn't in the field the colour is shown because the text field will be visible.

I'd prefer the colour to be available all the time, but I like the masked edit controls date entry even less that the date controls enrty style. Besides which the date control supports more formats.

This gives me the best of both worlds, with little compromise.

Thanks again.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access Search and Replace Using VBA 6 80
message box in access 4 51
Set email body to html using vbscript 6 49
Sub or Function is not defined 6 43
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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