Hello,
In my form I have a 2 fields for dates. The first is for a reservation date and the second is when we accepted the reservation. The “Date Taken” field should never be higher than today’s date. How can I set that field to be a date equal to or less than today?
W10, LO 6.3.2.2, MySQL Backend
Thank you
Hello,
Don’t know of any way to do this except with a macro. You do not state what is to happen if the date entered is greater than today - erase & message to user or insert today’s date or something else? Of course any macro provided will need to be adjusted for your form. Also are these separate date controls or controls within a table grid control?
Ideally, I would like the drop down calendar grey out dates that are not valid but anything that would either “ring a bell” and get the user’s attention that the date is not valid would be fine.
Hello,
I know of no method to modify the drop down calendar.
Attached is a sample using a macro. The macro is attached to the Before record action event of the internal form. When attempting to update a record (or enter a new one) the date value is retrieved and checked against the current date. If the entered date is greater than today a message is displayed, the cursor is positioned within the date control and the update is cancelled.
Edit:
It struck me to use a macro to change the Max Date allowed for a control. Have added a second form to the sample (Reservations1) which does this. It also covers your drop down date concern. If a date greater than today is selected, the current date is used. There is a drawback. The macro is attached to the Open document
event of the form. That means when the form is opened the max value is set. Now if the actual date changes while the form is open the value will not change. The form must be closed and opened again.
Sample ----- DateNotGreaterThanToday.odb
The first macro is still available and used on form → Reservations.
The first macro (pop-up warning) seems more attractive to me.so Thank You kindly!
My date field is on a sub-subform. Getting to the first subform requires using “oSubForm = oForm” etc. How do I get to the next subform?
Once you have the main form (oForm) you use that to get the subform such as:
oSubForm = oForm.getByName("YOUR_SUBFORM_NAME")
Then you can use oSubForm to get the control wanted.
I get an error “Variable Not Found”. My date field is on a subform to a subform.
Sorry, did not read your comment correctly. Again using the previous statement output get the subsubForm:
oSubSubForm = oSubForm.getByName("YOUR_SUBSUBFORM_NAME")
It is a matter of accessing levels of a form. Keep accessing the next level until you get to where the actual control is located.