Ask Your Question
0

max date=today

asked 2019-11-04 15:33:48 +0100

jodybingo gravatar image

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

edit retag flag offensive close merge delete

Comments

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?

Ratslinger gravatar imageRatslinger ( 2019-11-04 17:17:16 +0100 )edit

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.

jodybingo gravatar imagejodybingo ( 2019-11-04 17:36:21 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-11-04 21:31:29 +0100

Ratslinger gravatar image

updated 2019-11-05 00:19:05 +0100

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.

edit flag offensive delete link more

Comments

The first macro (pop-up warning) seems more attractive to me.so Thank You kindly!

jodybingo gravatar imagejodybingo ( 2019-11-05 03:36:33 +0100 )edit

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?

jodybingo gravatar imagejodybingo ( 2019-11-05 16:32:20 +0100 )edit

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.

Ratslinger gravatar imageRatslinger ( 2019-11-05 17:10:48 +0100 )edit

I get an error "Variable Not Found". My date field is on a subform to a subform.

jodybingo gravatar imagejodybingo ( 2019-11-05 17:16:43 +0100 )edit

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.

Ratslinger gravatar imageRatslinger ( 2019-11-05 18:18:05 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-04 15:33:48 +0100

Seen: 50 times

Last updated: Nov 05