DLookUp - Syntax

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
 
Would it make a difference if the form is Build From A Query Vs a table?
 
You haven't put the quotes round the field name and table name.

Code:
=DLookUp("APN","Access_Agreement","Well_ID = '" & [Well_ID] & "'")
 
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.
 
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.
 
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] & "'")
 
which is what was suggested in post #2 - the Me. should not matter
 
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
 
=DLookUp("APN","Access_Agreement","Well_ID = " & Me.Well_ID & "")
IF Well_ID Not text
 
=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

Back
Top Bottom