Garcimat
Member
- Local time
- Today, 10:30
- 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
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
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

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