Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup Help???

Status
Not open for further replies.

AccessDevJunior

Programmer
Apr 14, 2004
81
GB
hya,

im still having problems with Dlookup, i have a form with the following code on the timerinterval.
Nothing happens when the date and time match??? does anyone know why?

Private Sub Form_Timer()
If DLookup("[Date]", "tblCallRecords", _
"[Date] = Date()") And DLookup("[Time]", "tblCallRecords", _
"[Time] = Time()") Then

'Code for sending e-mail

End If

End Sub
 
What I typically do is create variables to assist with debugging... Also, the IF Statement is suppose to return as Logical (True/False), not sure what u are attempting to check.

Dim ldDate as Date
Dim lcTime as ? - Not sure if u have a text field here?

ldDate = DLookup("[Date]", "tblCallRecords", "[Date] = Date()")

lcTime =DLookup("[Time]", "tblCallRecords", "[Time] = Time()")

'See what DLookup returns if it does not find a match.

If ldDate = What? And lcTime = What? Then
Or
If ldDate <> What? And lcTime <> What? Then

xxx

End if


htwh,

Steve Medvid
&quot;IT Consultant & Web Master&quot;

Chester County, PA Residents
Please Show Your Support...
 
what ive done now is the forms record source comes from a query and brings back all the records where [Call Back Date] = Date().
I have also added two unbound text boxes on my form one called [MyDate] and one called [MyTime]. [MyDate] = Date() and [MyTime] = Time().
So what ive got now is a tabular form listing all the call backs for today.
what i want the timer to do is when real time matches the call back time the user receives an email.

the code is now as follows:

Private Sub Form_Timer()
Me.Form.Requery
If Me.Call_Back_Date = Me.MyDate And Me.Call_Back_Time = Me.MyTime() Then

'code for sending email

this does not work. am i on the right track or should i use your example?
 
You may try this:
If DCount("*", "tblCallRecords", _
"[Date]=Date() And Int(48200*[Time])=Int(48200*Time())) Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top