?Perhaps the field being DLookedUp has a null value, even though a record
exists?
Regards
Jeff Boyce
Microsoft Office/Access MVP
Nope. The field I am looking up is not null. The dlookup function
works fine on my computer, as well as most of the users' computers.
There are a few computers it does not work on though. This is my
code, so you know what's happening:
Public Function CheckForOverDueTickets()
Dim MyForm As Form
Set MyForm = Forms![frmSplash]
Dim ComplaintHours As Long, MyCompDate As Date, MyCompAccount As Long,
TradeHours As Long, TradeDate As Date, TradeAccount As Long
On Error GoTo NoComplaint
MyCompDate = DMin("[StartTime]", "[ComplaintTickets]",
"[ComplaintTickets].StatusID=2")
ComplaintHours = DateDiff("h", MyCompDate, Now)
Forms![frmSplash]![CompDate] = MyCompDate
Forms![frmSplash]![CompDif] = ComplaintHours & " Hours Unresolved"
MyCompAccount = DLookup("[Account]", "[ComplaintTickets]",
"ComplaintTickets.StartTime=Forms![frmSplash]![CompDate]")
Forms![frmSplash]![CompAccount] = MyCompAccount
GoTo TryTrades
NoComplaint:
MyForm![CompLabel].Visible = True
MyForm![CompDate].Visible = False
MyForm![CompAccount].Visible = False
MyForm![CompDif].Visible = False
MyForm![NoComplaints].Visible = True
TryTrades:
On Error GoTo NoTrade
TradeDate = DMin("DAT", "[Pending Tickets]", "[Pending
Tickets].Status=2")
TradeHours = DateDiff("h", TradeDate, Now)
Forms![frmSplash]![TradeDate] = TradeDate
Forms![frmSplash]![TradeDiff] = TradeHours & " Hours Unresolved"
TradeAccount = DLookup("[Account]", "[Pending Tickets]", "[Pending
Tickets].DAT=Forms![frmSplash]![TradeDate]")
Forms![frmSplash]![TradeAccount] = TradeAccount
Exit Function
NoTrade:
MyForm![TradeLabel].Visible = True
MyForm![TradeDate].Visible = False
MyForm![TradeAccount].Visible = False
MyForm![TradeDiff].Visible = False
MyForm![NoTrades].Visible = True
End Function
On my computer as well as most other computers, this works fine. On a
select few computers (2 to be exact), the dlookup function for the
account number throws a null error. I have went back into the
database and looked up the record with the date which is returned by :
MyCompDate = DMin("[StartTime]", "[ComplaintTickets]",
"[ComplaintTickets].StatusID=2") and there are no problems with it.
There is an account number there.