Full Version: Dlookup Text In Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
RAZMaddaz
Below is the formula I am using and I cannot get it to work. I can do the same thing in a Query with no problem, what's the scoop?

=DLookUp("[ID]","[Temp4]","[Name]='" & [Name] & "'")

Also, here is a copy of the table.

Thanks!!!!

RAZMaddaz
Peter46
You have too many [Name]s. ACcess doesn't know what you mean.

Change the name of the textbox containing the name field to txtName and you can then use..

=DLookUp("[ID]","[Temp4]","[Name]='" & [txtName] & "'")
RAZMaddaz
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!

I'm sorry to waste your time!!!!!

RAZMAddaz
Peter46
No problem

Glad to have helped.
LPurvis
Sorry, I know this isn't current now, but since this thread was linked to I thought I'd mention something.

I absolutely agree that changing the name (ideally both the textbox control and any field to which it's bound) is vital. Working on with that is just giving you potential problems for no reason or gain. Changed as you have and all's well.

Just thought I'd mention that Access isn't totally clueless here about your intent.
It sees [Name] and resolves that property.
If the field or control were called something else (i.e. txtName ;-) then that property exists independently. Access has created that property for the field/control.
But with [Name] you're out of luck - that fundamental property already exists. It's resolved.
You're getting the name of the Form returned - not a field value. It's quite likely that you don't want to perform the DLookup based on the form name (though entirely possible).

As with many cases though - what allows you to tell Access what you what is disambiguation.
For example
=DLookUp("[ID]","[Temp4]","[Name]='" & Form.[Name] & "'")
gives you the property, the name of the form.
=DLookUp("[ID]","[Temp4]","[Name]='" & Form![Name] & "'")
returns the control value.

I'm a big proponent of appropriate use of dot and bang. I like to think example this spells out why quite nicely.
Albeit for an example that should never be required - as Name is a name to be avoided. ;-)

Cheers.
theDBguy
QUOTE (LPurvis @ Mar 9 2010, 03:47 AM) *
Sorry, I know this isn't current now, but since this thread was linked to I thought I'd mention something.

I absolutely agree that changing the name (ideally both the textbox control and any field to which it's bound) is vital. Working on with that is just giving you potential problems for no reason or gain. Changed as you have and all's well.

Just thought I'd mention that Access isn't totally clueless here about your intent.
It sees [Name] and resolves that property.
If the field or control were called something else (i.e. txtName ;-) then that property exists independently. Access has created that property for the field/control.
But with [Name] you're out of luck - that fundamental property already exists. It's resolved.
You're getting the name of the Form returned - not a field value. It's quite likely that you don't want to perform the DLookup based on the form name (though entirely possible).

As with many cases though - what allows you to tell Access what you what is disambiguation.
For example
=DLookUp("[ID]","[Temp4]","[Name]='" & Form.[Name] & "'")
gives you the property, the name of the form.
=DLookUp("[ID]","[Temp4]","[Name]='" & Form![Name] & "'")
returns the control value.

I'm a big proponent of appropriate use of dot and bang. I like to think example this spells out why quite nicely.
Albeit for an example that should never be required - as Name is a name to be avoided. ;-)

Cheers.

Very well done, Leigh. As always, thanks for taking the time to set us straight. I really enjoy reading your posts. thumbup.gif cheers.gif
LPurvis
cool.gif Any opportunity to big up the dot/bang issue. :-)
SOS_UA
Hmm, would that qualify as the Big BANG theory? doh.gif
LPurvis
Well, I suppose if we consider "Dot" to be a "point", then it is without dimension. We could then consider that as a singularity and then kabluee - Bang. lol

Dot Bang -> Big Bang in three easy steps.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.