Lookup (1 Viewer)

mike60smart

Registered User.
Local time
Today, 13:44
Joined
Aug 6, 2017
Messages
1,908
Hi Everyone

I have the following data in a Table named "tblCurrencyCalculations"


CurrencyIDCurrencyUSDEUROAUDGBPCADINRMXNJPY
1​
USD
1​
1.156454​
0.730939​
1.362368​
0.796875​
0.013366​
0.048532​
0.008972​
2​
EURO
0.864712​
1​
0.632041​
1.178037​
0.689056​
0.011557​
0.041965​
0.007758​
3​
AUD
1.368431​
1.582528​
1​
1.86386​
1.090207​
0.01829​
0.066397​
0.012275​
4​
GBP
0.734036​
0.848879​
0.536521​
1​
0.584919​
0.009811​
0.035623​
0.006586​
5​
CAD
1.255114​
1.451482​
0.917257​
1.709638​
1​
0.016775​
0.060903​
0.011259​


On My Form I have a Control named "Currency"

In another Unbound Control I need to lookup a value from the tblCurrencyCalculations.

So, If ([Currency]="USD",Dlookup to retrieve the value in Row 1 Column GBP (1.362368)

I just can't get the syntax to work for me.

I have tried :- =IIf([Currency]="USD",DLookUp("USD","tblCurrencyCalculations","Currency = '" & [Currency] & "'"))

This returns a figure 1

Any help appreciated
 

oleronesoftwares

Passionate Learner
Local time
Today, 05:44
Joined
Sep 22, 2014
Messages
1,159
Use the currency id in the dlookup as parameter




=DLookup("[GBP]", "tblCurrencyCalculations", "[CurrencyID] =" _
& Forms![currentform]!CurrencyID)
 

bastanu

AWF VIP
Local time
Today, 05:44
Joined
Apr 13, 2010
Messages
1,402
Actually I think you need to make the column you search dynamic:
=DLookup(""" & Forms![frmYourForm]!UnboundControl] & """, "tblCurrencyCalculations", "[Currency] ='" & Forms![frmYourForm]![Currency])
Cheers,
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:44
Joined
May 7, 2009
Messages
19,233
i think all your conversion is in GBP?

=Dlookup("GBP", "tblCurrencyCalculations", "[Currency]='" & [Currency] & "'")
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:44
Joined
Feb 19, 2013
Messages
16,607
I have tried :- =IIf([Currency]="USD",DLookUp("USD","tblCurrencyCalculations","Currency = '" & [Currency] & "'"))

This returns a figure 1

It will do - according to your table, the value in the USD column when currency=USD is 1

ah- arnel got there before me
 

Minty

AWF VIP
Local time
Today, 13:44
Joined
Jul 26, 2013
Messages
10,368
Although that table design is great for a human to look up, it's poor for a database.
You should have

CurrID, BaseCurr, ComparisonCurr, Rate
tblCurr tblCurr

CurrencyIDBaseCurrencyComparisonCurrRate
2​
USDUSD
1​
3​
EUROUSD
0.864712​
4​
AUDUSD
5​
GBPUSD
6​
CADUSD
7​
INRUSD
8​
MXNUSD
9​
JPYUSD
10​
USDEURO
11​
EUROEURO
12​
AUDEURO
13​
GBPEURO
14​
CADEURO
15​
INREURO
16​
MXNEURO
17​
JPYEURO
18​
USDAUD
19​
EUROAUD
20​
AUDAUD
You get the idea.
 

mike60smart

Registered User.
Local time
Today, 13:44
Joined
Aug 6, 2017
Messages
1,908
i think all your conversion is in GBP?

=Dlookup("GBP", "tblCurrencyCalculations", "[Currency]='" & [Currency] & "'")
Hi Arnelgp

That is spot on.

Minty
Yes I know it is not ideal but that is what the current users are working with.
I will try to convince them to change.

Many thanks everyone for the help
:)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:44
Joined
Feb 19, 2002
Messages
43,223
Don't you also need a date in the table?

I've attached a sample that will allow you to use the properly normalized schema shown by Minty and still give your users a form that looks like a spreadsheet.
 

Attachments

  • Bound Denormalized Forms.pdf
    351 KB · Views: 234
  • BoundDenormalizedForm_20210319.zip
    1.5 MB · Views: 250

Users who are viewing this thread

Top Bottom