Dlookup error

mborg

New Member
Joined
Nov 22, 2010
Messages
43
Hi,
I have the following dlookup formula in a field in a form:
=DLookUp("[ID]","[HRMS]","[E-mail]=" & [E-Mail Address])

I am trying to populate the ID from the HRMS Table, where E-Mail(from HRMS table) = E-maill address on the form...

Thanks.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try adding text qualifiers around your email address, i.e.
Code:
[COLOR=#333333]=DLookUp("[ID]","[HRMS]","[E-mail]='" & [E-Mail Address] & "'")[/COLOR]
 
Upvote 0
You are welcome!
Is there any way to make the field editable after the lookup. Let's say the user enters an email address, but for some reason they want to change the ID field.

Essentially, I have a bunch of fields that will hinge on the email address. I added the lookup formulas to all of those, but would also like the user to be able to override..
 
Upvote 0
Calculated fields are not editable. The underlying fields in the table would be.

If you want the values to be editable, perhaps take a look at a Form/Subform relationship between your two tables.
There, you can supply the underlying fields from both tables (one table in the Form, the other in the Subform), and they should be editable.
There are lots of tutorials on how to create Subforms in Access, if you are unfamiliar with that. Just do a Google Search. I like YouTube tutorials myself, as I am a very visual person.
 
Upvote 0
So, I am running into another issue. I rarely use Access, so your help is hugely appreciated.

In the form, i enter an email address which populates several fields, one being the employee ID which is a primary field. When I try to move forward in the form, I get an error message that no primary key is found or null. something to that effect. When I take out the Dlookup function and change control source to Employee ID, the table updates correctly and I can move forward. Any ideas?? I am hoping this is just a quick fix.. It was working fine before with dlookup, but i must have done something. Many thanks!
 
Upvote 0
It is a bit difficult to understand the full nature of the problem without having a complete understanding of your database structure.

However, primary key field cannot be calculated fields (i.e. they cannot de DLOOKUP calculations).
They CAN be calculated by a DLOOKUP, but then the value would have to be hard-coded into the field as a value (something like that could be done via a DLOOKUP in VBA).
 
Upvote 0

Forum statistics

Threads
1,221,710
Messages
6,161,445
Members
451,706
Latest member
SMB1982

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top