Dlookup not showing result (1 Viewer)

sbaud2003

Member
Local time
Today, 14:46
Joined
Apr 5, 2020
Messages
48
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, 10:16
Joined
May 23, 2011
Messages
3,754
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, 10:16
Joined
Sep 21, 2011
Messages
5,753
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, 14:46
Joined
Apr 5, 2020
Messages
48
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, 04:16
Joined
Jan 30, 2020
Messages
586
After update event of the changed field/record/form:

me.dlookupfieldname.requery
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:16
Joined
Feb 19, 2002
Messages
28,769
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 (Users: 0, Guests: 1)

Top Bottom