terpsichore
asked on
Show date picker in VBA
Dear experts -
This one has me scratching my head.
I want to show the date picker for a date field on a form under certain conditions, but not in others.
I see there is a property 'showdatepicker' available in VBA; apparently the values are 0 (=never) and 1 (=for dates).
I've tried setting these in multiple places (open event, load event, current event) and nothing seems to work. For what it's worth, I've tried changing the property and when I query the value in the immediate window it seems to have been changed to those above.
But the darn date picker still shows up in all cases.
If I go into the form and manually turn the setting to 'never' for the relevant fields, the date picker does not show up in any case.
Any thoughts?
Thanks!
This one has me scratching my head.
I want to show the date picker for a date field on a form under certain conditions, but not in others.
I see there is a property 'showdatepicker' available in VBA; apparently the values are 0 (=never) and 1 (=for dates).
I've tried setting these in multiple places (open event, load event, current event) and nothing seems to work. For what it's worth, I've tried changing the property and when I query the value in the immediate window it seems to have been changed to those above.
But the darn date picker still shows up in all cases.
If I go into the form and manually turn the setting to 'never' for the relevant fields, the date picker does not show up in any case.
Any thoughts?
Thanks!
Have this code inside the else clause of your "certain conditions" (meaning "not in the others").
Of course, it depends how you got your datepicker (I just got it from the MS controls), and may not even work if you got a specialised one that doesn't have the Visible property.
Me.DTPicker1.Visible = False
Of course, it depends how you got your datepicker (I just got it from the MS controls), and may not even work if you got a specialised one that doesn't have the Visible property.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll award the points here - but the behavior is still anomalous for me.
If I view in FORM view, these properties seem to apply, but not in datasheet view.
The solution that worked for my purposes: I set the property to NEVER in the form and saved the form.
Then, in the Current event, I set the property to '1' - it only seems to apply to the form view. The Datasheet view is unaffected.
(I tested Scott's logic but turning one date field to show the picker and one not, and that works fine, just as he described.)
Thank you -
If I view in FORM view, these properties seem to apply, but not in datasheet view.
The solution that worked for my purposes: I set the property to NEVER in the form and saved the form.
Then, in the Current event, I set the property to '1' - it only seems to apply to the form view. The Datasheet view is unaffected.
(I tested Scott's logic but turning one date field to show the picker and one not, and that works fine, just as he described.)
Thank you -
If I view in FORM view, these properties seem to apply, but not in datasheet view.Ahh ... datasheet view. Yes, that would be much different than Form view, and I would not expect that toggle to work in datasheet view (since Access is essentially drawing the same control over and over, and cannot differentiate between distinct controls).
ASKER
thank you - I guess this gets to the root cause of the issue. I still would like a way to programmatically change this for ALL records in datasheet view, via VBA - let me know if you have a trick. otherwise, this is working ok now.
Continuous Forms view allows the toggle, and you could create one that looks very much like a Datasheet. If your form is complex, of course, it might not be worth the hassle to do that.
ASKER
thank you.
Ron