Add 6 or 12 months based on option in CBO box (1 Viewer)

MGF23

New member
Local time
Today, 04:04
Joined
Aug 28, 2020
Messages
4
Hi Folks,

I'm after some direction: On my form I have a date field called 'date of calibration' . I also have a combo box with the following two options:

"every 6 months"
"every 12 Months"

What i'd like to do (for example) is enter a date in the 'calibration date' field. I then want to select a schedule (either 6 months or 12 months) from the combobox.

If i select '6 months' then 6 months is added onto the calibration date and shown in a text box, likewise if '12 months' is added then that is added onto the date of calibration.

I know in reality this seems superfluous, because you can easily (mentally) add 6 or 12 months to a given date, but think would be good functionality for my DB.

Any pointers would be appreciated.

Cheers!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:04
Joined
Aug 30, 2003
Messages
34,748
Use the DateAdd() function, with the combo in the quantity argument. The combo should just return a number 6 or 12, which can be in a hidden column if you want the user to see "6 months".
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:04
Joined
Sep 21, 2011
Messages
7,172
I would create a second column in the combo with the actual value, and then just use that for the arithmetic.?

Saves having to do an If Else.
Or use the Split() function to obtain the value.?
 

neuroman9999

Member
Local time
Yesterday, 22:04
Joined
Aug 17, 2020
Messages
836
MG,

What you may have not covered, if it is even relevant, is that you might want to store all historical data regarding your ""dates of calibration"". If you simply go changing a date in a box, the old one obviously disappears. and if the box is linked to a table field, your old data is gone. Most people that I've known have always wanted to store technical data, regardless of what it is. and if you're calibrating ""anything"", I would assume you would want to know all of the dates that this event happened.
 

MGF23

New member
Local time
Today, 04:04
Joined
Aug 28, 2020
Messages
4
MG,

What you may have not covered, if it is even relevant, is that you might want to store all historical data regarding your ""dates of calibration"". If you simply go changing a date in a box, the old one obviously disappears. and if the box is linked to a table field, your old data is gone. Most people that I've known have always wanted to store technical data, regardless of what it is. and if you're calibrating ""anything"", I would assume you would want to know all of the dates that this event happened.

That's a great observation! For this case a history is not critical...but thinking about it I like the idea of a history. I'll have to have a think about this....
 

neuroman9999

Member
Local time
Yesterday, 22:04
Joined
Aug 17, 2020
Messages
836
That's a great observation! For this case a history is not critical...but thinking about it I like the idea of a history. I'll have to have a think about this....
well good for you. glad to provide something of value. good luck to you. :)
 

Users who are viewing this thread

Top Bottom