Built-in Date-Picker issue

EasyCarlo

Registered User.
Local time
Tomorrow, 04:20
Joined
Dec 26, 2014
Messages
11
Hi There,

Access 2007 - Win7
I have two textboxes in my form bounded respectively to check-in and check-out dates of my Hotel_Bookings table

When a user enters the check-in date, I'd like the date-picker of the check-out date to display the same month of the check-in date instead of the current month.

I know that the built-in date picker cannot be manipulated
I cannot work on check-out default value because it will not be updated on the current record
The only way that I've found until now is to set the check out value to check in + [some days] but I do not like it because it could generate data entry mistakes

How can I solve? If there is no way to get the job done with the built-in date picker, what kind of ActiveX control could I use instead? And where to find it?

Many thanks in advance for any kind of help
Carlo
 
Hi Smig and thank you

I've been testing your date picker and saw it works well on forms but gave me some problems on subforms. It may depend on some specific settings and configurations of my project or Access version but I would like to give you a feedback anyway

The first issue is regarding the Form variable required by the fnDatePick function. It looks to me like it does not accept subforms...
I've tried passing the frm variable as
Forms!Subformcontrolname.Form
Forms.Controls(Subformcontrolname).Form
but did not work. The ClickOK function fails and the reason may be that the form name is passed as a string by the OpenDatePicker OpenArgs which works perfectly for forms but maybe not for subforms....
I've turned around this by declaring a public MyForm As Form variable recalled by the ClickOK functios. Not nice to see but it works! :-)

The second isuue unfortunately goes beyond my programming capabilities and has to do with the positioning of the date picker on subforms, especially if the subform displays multiple records (I would like to use the date picker in a Continuous Forms Subform with last record as data entry). It looks like the positioning by Top and Left relative to the form window and textbox relative position doesn't take the height of existing records into account and, on different records, the date picker always opens to a different height related to the textbox, sometimes hiding it (and if the 1/42 dates area overlaps the clicking position on the textbox, the MouseDown/Click events on the datepicker are fired, automatically closing the datepicker with no chance to select any date!!).

Any suggestion on how to solve it?

I specify that acCmdSizeToFitForm fails on my project ("not avaiable now"). It may depend on loaded references (or their relative order) which anyway I cannot change....

Many thanks in advance for any kind of help

Carlo
 
You are right. it won't work very well with subForms
The problem with a subForm is that all controls on a continuous subForm has the same name so it won't know where to position itself and into what Textbox to put the selected date.

*** Edit ***
I did some tests.
Problem is when you click the picture it won't recognize the record you are currently in, so it might stick the Date into a wrong record.
I can't find a way to make a picture recognize the correct record in a continuous form.
It will work only if you first select the record and click after.
 
Last edited:
in case someone is interested, here attached is a enhanced version of your Date Picker which works also on subforms and forms in multipleForms view

The DP opens on the Top-Right corner of the Date textbox control which refers to, with the following exceptions and limitations:

- the DP will fail on forms with no FormHeader Section and will not open at correct Height in forms with a PageHeader Section (as far as I know there is no way to check by code if Headers exist or not - can anydoby help?). To make things work, if FormHeader is not required, it is just enough to include it and size it at 0 height

- the DP will not open at correct Height if called from controls in records only displayable by scrolling the vertical bar (ie in a long list of records, totally exceeding the Height of the form window). It is anyway granted that the DP will never open below the form bottom line.

For a more precise positioning, it would be necessary to find the textbox absolute screen position...maybe by an API call which goes far beyond my capabilities

Some further enhancements:
- the DP default date displayed on open can now be related to other existing parameters (as per my initial needs)
- dates are highlighted at MouseMove

This DP works well on my environment but I did not thoroughly tested it. Any feedback is appreciated.

Carlo
 

Attachments

Users who are viewing this thread

Back
Top Bottom