Problem with dates.... Alarm, Automatic SMS (1 Viewer)

Garcimat

Member
Local time
Today, 14:42
Joined
Jun 7, 2022
Messages
67
Hi Guys

I have this date entry form, (IMAGE1) the user have to input the TIME (typing) Day (combo box) and DATE (Date Picker) I know It is silly but it has to be done like this, it is a legal requirement that the user write/choose this information.

The record inputted will generate a active Permit that will be displayed on the main page IMAGE2
These permits can not expire, otherwise people can get badly hurt, for example a train can be sent while people are still working on track.

I need to create alarms to warning the person running the show that permits are expiring.... I was thinking in create a sub form and do some validation using colours instead a list box as it is now, probably I will do it in the future for a visual reference.

Anyway I need to create alarms, my problem is: I need to put the Time+Date together (they are in different fields in the Table so I can get it in a query... I am playing with this query now (still have to do the alarms for 30 minutes and 0 minutes. zero minutes I system will return to frontpage frm_Welcome and change colour to red, send a sms to a senior person(not sure we can send sms with access) .... something like that) .... I am almost there :giggle: any suggestions ?

Sub CheckDates()
Dim db As Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim dteLast As Date
Dim dteThis As Date
Dim lngDiff As Long
Dim lngCount As Long

dteLast = Now()
lngCount = 0

Set db = CurrentDb
Set rst = db.OpenRecordset("Select [Permit_Number],[Record_Time] from tbl_data order by [Permit_Number]", dbOpenSnapshot)

Do Until rst.EOF
lngCount = lngCount + 1

dteThis = rst![Record_time]
If lngCount = 0 Then
lngDiff = 0
Else
lngDiff = DateDiff("n", dteLast, dteThis) 'Datediff(interval,date1,date2] Interval ( d=day, h=hour, n=minute, s=second)
End If

Debug.Print rst![Permit_Number] & " - " & lngDiff & " Hours Left"
dteLast = dteThis
rst.MoveNext
Loop

Set rst = Nothing
Set db = Nothing

End Sub
 

Attachments

  • image1.png
    image1.png
    36.3 KB · Views: 108
  • image2.png
    image2.png
    203.1 KB · Views: 112

Gasman

Enthusiastic Amateur
Local time
Today, 05:42
Joined
Sep 21, 2011
Messages
14,216
You can add/sum the Date and Time fields. They are just numbers after all?
If you are showing in hours, wouldn't you need to divide by 3600, as you are calculating in seconds? if you do not want to use the h parameter.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 00:42
Joined
Feb 19, 2002
Messages
43,196
Not sure what you need the time for. Each day when the database opens, run a query that selects all the permits with Expiration Dates > Date() + 7 or whatever range makes sense. Display the query in a form and allow the user to double click on a row to open that permit's edit form if you want to add a new permit.
 

Users who are viewing this thread

Top Bottom