Problems with DLookUp (1 Viewer)

gerryo

New member
Local time
Yesterday, 19:07
Joined
Dec 3, 2011
Messages
5
I have 2 tables, Securities and Transactions. In a form which I use to record a transaction, I have the text boxes Date, Symbol, SecurityName, BuyPrice and SellPrice. When entering the "Symbol" I would like to have the Security Name show, which is drawn from the Securities table. I tried this expression in the text box:

=DLookUp("SecurityName","SecuritiesT","[Symbol]="&[Forms]![TransactionsF]![Symbol])

When entering a symbol that is in the Securities table #Name? shows up as the Security Name. If it is not in the Securities table then a message appears saying "You cannot add or change a record because a related record is required in table "Securities'"

What am I doing wrong? Any help would be appreciated. Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:07
Joined
May 7, 2009
Messages
19,229
=DLookUp("SecurityName","SecuritiesT","[Symbol]='" & [Forms]![TransactionsF]![Symbol] & "'")
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:07
Joined
Oct 29, 2018
Messages
21,455
Hi gerryo. Welcome to AWF!
 

gerryo

New member
Local time
Yesterday, 19:07
Joined
Dec 3, 2011
Messages
5
Thanks arnelgp. I made your suggested change but I still get the same result.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:07
Joined
May 7, 2009
Messages
19,229
its better to create a Query against Transaction table Joined with SecuritiesT table on [Symbol] field.

select Transactions .*, SecuritiesT.[securityName] from Transactions Left Join SecuritiesT On
Transactions.[symbol] = SecuritiesT.[symbol];

use the query as the Recordsource of your form.
then add the securityName to your Form and get rid of the Unbound textbox.
 

gerryo

New member
Local time
Yesterday, 19:07
Joined
Dec 3, 2011
Messages
5
Thank you arnelgp it finally worked. Sorry for late reply but had sudden illness and death in the family and only now getting back to this project.
 

Users who are viewing this thread

Top Bottom