Dlookup not showing result (1 Viewer)

sbaud2003

Member
Local time
Today, 19:45
Joined
Apr 5, 2020
Messages
170
Hi I am very new to access.. and I using the code below which returns only one result
TXTUTR=Dlookup("utr_number", "ecs", " payment_sl_no=forms! Formamount! COMPMT and forms! Formamount! COMFY)
 

bob fitz

AWF VIP
Local time
Today, 14:15
Joined
May 23, 2011
Messages
4,717
Your syntax is incorrect.

Can you explain your criteria.
At the moment you appear to want a record where "payment_sl_no" equals both "COMPMT" AND "COMFY". That will only happen if they are both the same. Perhaps you meant OR.

Also, what is the Data Type of the field called "payment_sl_no".
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:15
Joined
Sep 21, 2011
Messages
14,042
Also a DLookup will only return one result, the first one it finds.?

As Bob stated, you probably mean OR but even then it should be

Code:
TXTUTR=Dlookup("utr_number", "ecs", "payment_sl_no=forms!Formamount!COMPMT OR payment_sl_no= forms!Formamount!COMFY")

HTH
 

sbaud2003

Member
Local time
Today, 19:45
Joined
Apr 5, 2020
Messages
170
Thanks all of you
Yes the result should be one record only.
But when payment_sl_no gets changed the value does not change.
It is a numeric field and controlled thorough a combo box and COMFY is the financial year again a numeric field through combo
 

zeroaccess

Active member
Local time
Today, 09:15
Joined
Jan 30, 2020
Messages
671
After update event of the changed field/record/form:

me.dlookupfieldname.requery
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:15
Joined
Feb 19, 2002
Messages
42,970
If the values come from a combo are you sure the bound value is not numeric? That would be the normal situation. So you wouldn't be looking for

Somefield = "COMPMT" OR Somefield = "COMFY"

You would be looking for

Somefield = 987 OR Somefield = 123

Using of course the actual numerical values that correspond with the two strings.
 

Users who are viewing this thread

Top Bottom