msg box

smash54

Registered User.
Local time
Yesterday, 21:05
Joined
Nov 5, 2010
Messages
23
Hello im trying to make a msgbox pop up if the date and time are the same as the ones on a form. What i have been trying is this

If Time() = [fmdata].[Time] And Date = [frmdata].[Date] Then
MsgBox "Send AQIM", vbYesNoCancel, "AQIM NOW"
End If

Nothing happens any help would be great thanks
 
What value does [fmdata].[Time] hold, and how is it populated?

Also you do realise that you will need to have a match to the second on Time() and [fmdata].[Time] for your code to work.
 
Separating Time and Date storage is rarely a useful thing. Even when they aew hwld as a single value the time and date can be displayed separately very easily using the Format property of the field or control.

Time comparisons are notoriously problematic due to rounding errors because time is held as decimal parts of a day. Comparisons that include time should always be done with the DateDiff function.

However even with this your comparison is very unlikely to ever match unless you were running the code very frequently since there is no scope for any decrepancy.

Test for the Date/Time being before Now().
 
Ok what im looking at doing is I have a list of times and dates when that date and time come up I want a way to alert a person that is at that computer to do something. I was thinking a message box that pops up would alert them. Also I do see that error [fmdata] it was to be [frmdata] but still nothing. That form was just showing the tbldata that just has 2 fields data and time.
 
This is going to be very resource intensive as you are going to have to check the system date and time at least once every minute. And what happens in a multi user environment more than one person will se this message within the same time span. That is of course that the different users have the same date and time on their pc's.
 
This will only be running on one computer and thats what i was thinking repeat that little code once a minute. where do you think i should put that code and is that even a good way to do it.
 
Ok i put that cade in the timmer and now everytime i open that form the message box pops up and i cant get ride of it. If I get ride of all the data in the table it wont show but even if the time is diff the box pops up
 
Can't comment directly without see what code you are using.

However as part of your pop up box you will have to re-set your timer trigger point to a new future trigger point.
 
Private Sub Form_Timer()
If Me.[Time] = Time() And Me.[Date] = Date Then
MsgBox "Send AQIM", vbYesNoCancel, "AQIM NOW"
End If
End Sub
 
You are using reserved words as control names. Further you have not paid any attention to the advise given, on comparing times, by GalaxiomAtHome re. the compassion of time values.
 

Users who are viewing this thread

Back
Top Bottom