473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

DtPicker - weird behaviour

8,435 Expert 8TB
Hi all.

Short version: DtPicker goes strange when .Enabled changed in VBA code, looking for solution or good workaround.

Looooong version:
Those of you who have been following various threads here will know that I have a fairly large Access 2003 database (actually split over multiple backend databases and a front-end), which users search by entering criteria on a form.

Among these criteria are three date/time fields. For each, I have a pair of date/time picker controls in which the user chooses a from and to value, to limit the search to a date/time range. Initially I was simply checking the values and generating WHERE clauses based on whether they had been changed from their default values. However, this is proving more complex than I like, due to relationships (real-world, not database) between the three pieces of chronological information. So I’ve placed a checkbox next to each pair, with the intention of requiring the user to “turn on” each criterion they want to use. (Normally the user won’t be interested in these criteria).

Here’s my problem, though. When the checkbox is clicked and I turn off the .Enabled property of a date/time picker, it loses it’s custom format (which shows date and month down to the minute) and switched back to showing just the short date. Worse still (much worse), when enabled again, it turns into a blank box, and the date/time entry field appears at the top-left corner of the form. Turning .Visible property on or off does seem to work, but I would prefer to leave the control visually disabled rather than hide it completely. If I do that, I'll have to put something else there to indicate what the checkbox is for (since unlike VB6, Access helpfully hides the label along with the control.)

I don’t know what we can do about this, but figured I’d ask anyway.

On the other hand, does anyone have a good suggestion on another way to visually enable/disable the date/time picker controls when the user hits the corresponding checkbox? For the moment I have placed a red border around each one, and change it to green to indicate it’s enabled. Doesn’t look so good. :( I tried turning the .Locked property on/off, but it doesn’t seem to have any effect at all. Can’t find a ForeColor or BackColor property. Tried setting the CalendarBackColor (I think) but it only affected the popup calendar.
Nov 29 '06 #1
11 6151
NeoPa
32,556 Expert Mod 16PB
Try setting the .Visible property (Boolean).
This should have no effect on the control at all.
Nov 30 '06 #2
Killer42
8,435 Expert 8TB
Try setting the .Visible property (Boolean).
This should have no effect on the control at all.
Thanks NeoPa.

However, I have tried that. There are two problems, one minor and one which I consider a show-stopper.
  • When hidden, you have a checkbox sitting there for no apparent reason.
    This is the minor nuisance, it just means I would need to put something else on the form to indicate that this particular option is turned off.
  • When I make it visible again, it loses the custom format and goes back to the ugly short date format.
    This is a real problem of course, since it is (A) in Yank format, and (B) meant to include the time.
I've noticed quite a bit of weird behaviour like this from the dtpicker in Access. It seems to lose the custom format "at the drop of a hat". Almost anything I do causes it to revert to the American short date format. (At least I think that's what it was - haven't checked for a while).
Nov 30 '06 #3
Killer42
8,435 Expert 8TB
Try setting the .Visible property (Boolean).
This should have no effect on the control at all.
Seems a bit pointless then, wouldn't you say? ;)
Nov 30 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
If the control is locked the user can't change the value in the control.

You said you are using a custom format. Try setting it on the table instead of the control. This may solve your problem.

Mary
Nov 30 '06 #5
Killer42
8,435 Expert 8TB
If the control is locked the user can't change the value in the control.
You said you are using a custom format. Try setting it on the table instead of the control. This may solve your problem.
It's all unbound. The value is only being used in code to set up a query, once the user clicks "Go".

And the weird thing is, the .Locked option doesn't stop the user changing the value, as I had thought it would. Perhaps it only applies when bound to a field?

Thanks, anyway. I'm thinking I might give up on it for now, and just use either the silly-looking borders, or set .Visible on and off, and try to re-set the custom format each time (blah).
Nov 30 '06 #6
Killer42
8,435 Expert 8TB
Well, it's official - my date/timepicker control has gone insane.

I am now turning the .Visible property on and off when the user clicks the corresponding checkbox. Here's the code I intended to use in my checkbox click sub...
Expand|Select|Wrap|Line Numbers
  1. dtSubFrom.Visible = chkSubmitted.Value
  2. dtSubTo.Visible = chkSubmitted.Value
Due to the abovementioned insanity, here's the code I ended up with...
Expand|Select|Wrap|Line Numbers
  1.   If chkSubmitted.Value Then
  2.     ' dtSubFrom.BorderColor = vbGreen
  3.     ' dtSubTo.BorderColor = vbGreen
  4.     dtSubFrom.Visible = True
  5.     dtSubTo.Visible = True
  6.     dtSubFrom.CustomFormat = dtSubFrom.CustomFormat
  7.     dtSubTo.CustomFormat = dtSubTo.CustomFormat
  8.   Else
  9.     ' dtSubFrom.BorderColor = vbRed
  10.     ' dtSubTo.BorderColor = vbRed
  11.     dtSubFrom.Visible = False
  12.     dtSubTo.Visible = False
  13.   End If
  14.  
That's right - after making the control visible again, I have to restore the custom format to the same value which is already in it :(. Turning on .Visible (or possibly turning it off, who knows - or cares) switches it to displaying short date format (not American, I was mistaken). Setting the custom format overcomes the problem, even though the property already has the right value.

This is close enough - I give up!
Dec 1 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Why do these things always happen to you ? :D


Mary
Dec 1 '06 #8
Killer42
8,435 Expert 8TB
Why do these things always happen to you ? :D
I can't help wondering the same thing.
Dec 1 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
I can't help wondering the same thing.
Have you upset anyone lately with the power to put a hex on you ?
Dec 1 '06 #10
Killer42
8,435 Expert 8TB
Have you upset anyone lately with the power to put a hex on you ?
Well, only Mary.

Oh no, did I actually type that? Quick, where's the delete...
Dec 1 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Well, only Mary.

Oh no, did I actually type that? Quick, where's the delete...
I WILL have my revenge! Watch out.

That's both you and Adrian with a black mark.

Hmm, have to consult my spellbook. Eye of Newt, leg of frog, now what was that other incredient for giving someone boils in unpleasant places. Never mind it will come back to me eventually.

Mary
Dec 1 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Theo | last post by:
Hi Guys, A silly question really, but how do I get the value of a DTPicker. I just need to get the value in session variable and display it on a different page. -----------------------------...
0
by: someone | last post by:
Hi, We are encountering a problem with the DTPicker. This is the situation: We have a DTPicker-control on a VB6 Active-X. The Active-X is used on a .NET winform. the problem: The .Net...
2
by: siyoyok007 | last post by:
Hello, I'm developing simple system, that needs the use of DTPicker. For my system, i have placed two dtpicker, which means DTPicker1 and DTPicker2. The DTPicker1 will be used as starting date and...
1
by: psuaudi | last post by:
I have a form that I was creating and I wanted to use the microsoft date and time picker. in the On_Load event for the form, I want to set the date and time picker value to Now() Private...
8
by: Sid666 | last post by:
Hi, everyone I'm building an Access DB system using VBA. I have a ActiveX DTPicker so the user can select a date. This date is put in another textbox that is bound to a table. I do this because...
2
by: blees10 | last post by:
Hey Guys, I have an issue with a dtpicker field in one of my forms. I developed this form using Access 2003 and everything works fine. Recently, I've been asked to deploy this database to...
1
by: venkatanarasimhaa | last post by:
Hi, I am developing a simple application in VB. I have one DTPicker on my form. If the value of DTPicker is not mindate of DTPicker, It should not be allow us to enter any value earlier than...
4
by: virusingh | last post by:
q.1How to use DTpicker in vb6 add , difference, between two date e.g one employee date of birth is 15/1/1987. and how we will use dtpicker to calculate its retirement date after completion a...
6
by: rudeman76 | last post by:
Hi, I have a form that is a daily log. I use dtpicker for the user to enter in the time. At form load, I set the time as the current time. The problem i am having is when the user changes the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.