How to uncheck a checkbox after 48 hours (1 Viewer)

saledo2000

Registered User.
Local time
Today, 10:20
Joined
Jan 21, 2013
Messages
94
Hi everybody,
Can you help me with some solution to uncheck checkbox after 48 hour pass. Will have date/time data field next to the checkbox where I will put desired date and time.

Please help with this issue because I am not that experienced in VB source code.

Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:20
Joined
Oct 29, 2018
Messages
21,467
Hi. What is the purpose of the checkbox itself? If you had a date/time value, you can easily check it against the computer's clock to know if it's expired or not.
 

saledo2000

Registered User.
Local time
Today, 10:20
Joined
Jan 21, 2013
Messages
94
I have some items which will expire in 48 hours and want to query whole list to know which one is expired. It is easy to have checkbox results in the query.
 

vba_php

Forum Troll
Local time
Today, 04:20
Joined
Oct 6, 2019
Messages
2,880
Hi. What is the purpose of the checkbox itself? If you had a date/time value, you can easily check it against the computer's clock to know if it's expired or not.
another great way to do this is to have 2 fields in your table - 1) datetime_initiated, 2) datetime_expired


that way, when you open ur form, all u have to do is compare the textbox values.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:20
Joined
Oct 29, 2018
Messages
21,467
I have some items which will expire in 48 hours and want to query whole list to know which one is expired. It is easy to have checkbox results in the query.
Hi. So, what field in your table designates the record's expiration date? For example, do you have a date field showing when the record is supposed to expire? A checkbox alone might be enough to find out which items "have" expired; but if you wanted to know how long ago they have been expired (and other related questions), a checkbox won't be good enough.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:20
Joined
Feb 28, 2001
Messages
27,156
If you have date/time of anticipated expiration in the record, then you don't need a checkbox at all. You are thinking too hard here.

Code:
SELECT * FROM ITEMTABLE WHERE EXPIRYDATE < Now() ;

That gets you everything that is expired. Having a separate checkbox is a waste of space and a waste of code to maintain it.
 

saledo2000

Registered User.
Local time
Today, 10:20
Joined
Jan 21, 2013
Messages
94
Hi thank YOU for the answers
I have internet shop and warehouse with 15000 products. According to my contract with shipping company I have to pay extra fees after 48 hours if I don’t sheep the products. My employees are careless some time and need to follow up these items. Order receive date is entered in the database. I need to compare that date and system time. That is why I need checkbox to be unchecked after 48 hours. It is easy for me to follow these item using query on checkbox.
Hope to understand my issue.
Thank you.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:20
Joined
Feb 19, 2002
Messages
43,257
No, you don't need a checkbox. That is what we are trying to tell you. If you use a checkbox rather than an expiration date, SOMEONE MUST REMEMBER to run an update query. and how frequently should they run the query? every 60 seconds, every hour? at some point something will expire but not be flagged because the update wasn't run. If you calculate an expiration date when the order is placed, you can easily tell what items have "expired" before they shipped.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:20
Joined
Oct 29, 2018
Messages
21,467
Hi thank YOU for the answers
I have internet shop and warehouse with 15000 products. According to my contract with shipping company I have to pay extra fees after 48 hours if I don’t sheep the products. My employees are careless some time and need to follow up these items. Order receive date is entered in the database. I need to compare that date and system time. That is why I need checkbox to be unchecked after 48 hours. It is easy for me to follow these item using query on checkbox.
Hope to understand my issue.
Thank you.

Hi. Please show us the query you're using to check for expiration with the checkbox, and we'll try to modify it for you.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:20
Joined
Feb 28, 2001
Messages
27,156
Each of us is telling you but you aren't seeing this. Pat said it more directly but I'll be flat out pedantic. (I'm good at that.)

To have a checkbox that gets unchecked at a certain time, you must run a query before that certain time. IF time of day to the second is involved, then you must run that query once per second AND have it do something special if at least one box was unchecked AND it gets even more complex if you need to know which ones were unchecked during that query. That is a problem I wouldn't have attacked even on my mainframe with the Navy.

Your solution is two dates: Date due and date shipped.

IF you are shipping now and NOW() is later than [DateDue], you have a late shipment.

If you are shipping now and NOW() is earlier than [DateDue], you are on time.

Now to capture that fact for posterity, store [DateShipped] from NOW() when you ship the package and in the future, you can generate your reports of on-time shipping by comparing [DateDue] vs. [DateShipped]. No checkbox needed and a query will easily be able to use those comparisons in selection criteria. You even can decide between shipped and not shipped by whether [DateShipped] = 0 or not.
 

Mark_

Longboard on the internet
Local time
Today, 02:20
Joined
Sep 12, 2017
Messages
2,111
According to my contract with shipping company I have to pay extra fees after 48 hours if I don’t sheep the products.

You really want to check after 24 hours to see if its has shipped OR if there is a good reason it hasn't. As a business, this should give you time to fix an issue so you don't get charged.

You'd normally have a DateOrderPlaced and a DateOrderShipped fields. You would want to see all orders that have a DateOrderPlace greater than 24 hours ago AND don't have DateOrderShipped. If you wait until you have to pay, you have to pay. Better to catch it BEFORE it becomes a problem.

Depending on your work cycle you can choose a more appropriate period to use (say 30 hour or even 40) but you definitely want to catch it before 2 days have passed.
 

saledo2000

Registered User.
Local time
Today, 10:20
Joined
Jan 21, 2013
Messages
94
Hi everyone.
Sorry for delayed answer. Yeah all of you have right, I think to complicated. I have created two records DateOrder and DateOrderShiped. That works fine with the query. Can you help me to automate process a bit having automation on the field DateOrder to save Now date to my Table. I have tried to set Date() on my table property DateOrder field but do not work. Some suggestions perhaps.
Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:20
Joined
Oct 29, 2018
Messages
21,467
Hi everyone.
Sorry for delayed answer. Yeah all of you have right, I think to complicated. I have created two records DateOrder and DateOrderShiped. That works fine with the query. Can you help me to automate process a bit having automation on the field DateOrder to save Now date to my Table. I have tried to set Date() on my table property DateOrder field but do not work. Some suggestions perhaps.
Thank you.
Did you try the DefaultValue property? Is that what you meant?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:20
Joined
Oct 29, 2018
Messages
21,467
Yes that is what I meant.
Okay, so if you put Date() in there, then you should see the current date automatically gets assigned/added for new records. Is that not happening, or is that not what you want to happen?
 

saledo2000

Registered User.
Local time
Today, 10:20
Joined
Jan 21, 2013
Messages
94
Okay, so if you put Date() in there, then you should see the current date automatically gets assigned/added for new records. Is that not happening, or is that not what you want to happen?

That is not happening.
 

Users who are viewing this thread

Top Bottom