Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error with DLookup

Posted on 2014-11-09
6
Medium Priority
?
171 Views
Last Modified: 2014-11-10
I am getting a #Error using a DLookup on a report..

Here is the control source for the field:

=DLookUp("[LastName]","tblEmployees","[ID] = " & [Reports]![rptOpenServiceEvents]![txtTechnician5])

How can I change this to the #Error goes away?
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:SteveL13
ID: 40431361
By the way... LastName is text and may be null.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40431398
It should read:

Dim lngID As Long
lngID = Nz([Reports]![rptOpenServiceEvents]![txtTechnician5], 0)
=DLookUp("[LastName]","tblEmployees","[ID] = " & lngID & "")

Of course, if rptOpenServiceEvents is not open, it will fail.

/gustav
0
 

Author Comment

by:SteveL13
ID: 40432576
Am getting invalid use of null with this solution.

Here is what I have which is a copy/paste in the onprint event of the detail section of the report...

    Dim lngID As Long
    lngID = Nz([Reports]![rptOpenServiceEvents]![txtTechnician5], 0) = DLookup("[LastName]", "tblEmployees", "[ID] = " & lngID & "")

Open in new window

0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 51

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 40432590
I got it mixed up, sorry. Try this:

=DLookUp("[LastName]","tblEmployees","[ID] = " & Nz([Reports]![rptOpenServiceEvents]![txtTechnician5], 0) & "")

/gustav
0
 

Author Comment

by:SteveL13
ID: 40432606
Perfect!   Thanks again.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40432611
You are welcome!

/gustav
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question