DLookUp - Syntax (1 Viewer)

ardy

Registered User.
Local time
Today, 11:24
Joined
Sep 24, 2012
Messages
98
try navigating for each value. in your expression builder, click on GWM_wellProfile, select the form, select the control for me.well_id
It seems to be Okay

EXP_Well_ID.jpg
 

ardy

Registered User.
Local time
Today, 11:24
Joined
Sep 24, 2012
Messages
98
Would it make a difference if the form is Build From A Query Vs a table?
 

cheekybuddha

AWF VIP
Local time
Today, 18:24
Joined
Jul 21, 2014
Messages
2,237
You haven't put the quotes round the field name and table name.

Code:
=DLookUp("APN","Access_Agreement","Well_ID = '" & [Well_ID] & "'")
 

ardy

Registered User.
Local time
Today, 11:24
Joined
Sep 24, 2012
Messages
98
You haven't put the quotes round the field name and table name.

Code:
=DLookUp("APN","Access_Agreement","Well_ID = '" & [Well_ID] & "'")
Bingo......... cheekybuddha
Dam I hate Access's Syntax stuff..... Is there a some white papers that you guys can point me to that tells you when you got to use what and what type of syntax well this works thanks a lot guys...... I really do appreciate this.
 

June7

AWF VIP
Local time
Today, 10:24
Joined
Mar 9, 2014
Messages
5,423
Do you have a combobox on form for user to select well? Include APN as a column then expression in textbox can reference that column by its index. If APN is in third column, its index is 2.
=cbxWell.Column(2)
Another option is to include the combobox's RowSource lookup table in the form's RecordSource and bind textbox to APN field with its properties Locked Yes and TabStop No.
This is more efficient than DLookup() as Domain Aggregate functions in query and on form can slow performance, especially with large datasets.
 

ardy

Registered User.
Local time
Today, 11:24
Joined
Sep 24, 2012
Messages
98
Do you have a combobox on form for user to select well? Include APN as a column then expression in textbox can reference that column by its index. If APN is in third column, its index is 2.
=cbxWell.Column(2)
Another option is to include the combobox's RowSource lookup table in the form's RecordSource and bind textbox to APN field with its properties Locked Yes and TabStop No.
This is more efficient than DLookup() as Domain Aggregate functions in query and on form can slow performance, especially with large datasets.
Thanks for the reply this worked

Code:
=DLookUp("APN","Access_Agreement","Well_ID = '" & [Well_ID] & "'")
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:24
Joined
Feb 19, 2013
Messages
16,553
which is what was suggested in post #2 - the Me. should not matter
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:24
Joined
Feb 19, 2013
Messages
16,553
I always thought that form control expressions had no concept of Me.

I stand corrected, you are right in the context of a form control. but post#2 was corrected in post #4 and restated again in post #11

Is there a some white papers that you guys can point me to that tells you when you got to use what

just google the function name e.g.


usually better to also include access and/or vba in your search string to produce a more focused list

or use the vba immediate window for a simpler intellisense guide
1652722448933.png
 

uncleh

Member
Local time
Tomorrow, 02:24
Joined
Mar 1, 2020
Messages
31
=DLookUp("APN","Access_Agreement","Well_ID = " & Me.Well_ID & "")
IF Well_ID Not text
 

cheekybuddha

AWF VIP
Local time
Today, 18:24
Joined
Jul 21, 2014
Messages
2,237
=DLookUp("APN","Access_Agreement","Well_ID = " & Me.Well_ID & "")
IF Well_ID Not text
The problem still exists with your solution - Me.Well_ID is not valid when the DLookup() is used in a fom control's ControlSource expression.

You just need to use [Well_ID] on its own.

Of course, when you use the DLookup() in VBA then Me is valid within the context of the form's Class module.
 

Users who are viewing this thread

Top Bottom