Help needed on Dlookup (1 Viewer)

Shiv

Registered User.
Local time
Today, 12:52
Joined
Dec 23, 2018
Messages
16
In my attached DB, i have made a query in which i am trying to fetch 'AVC Class Code' from 'Fare Table' through D LookUP but it is not working therefore please help me on the same.
 

Attachments

  • Database21.accdb
    492 KB · Views: 67

isladogs

MVP / VIP
Local time
Today, 08:22
Joined
Jan 14, 2017
Messages
18,261
The criteria for DLookup is
=DLookup(fieldname, table/query name, filter criteria)

However, don't use a DLookup.
Instead, add the Fare_Table to the query and join by field AVC_Class

Code:
SELECT Table1.[AVC Class]
FROM Table1 INNER JOIN Fare_Table ON Table1.[AVC Class] = Fare_Table.[AVC Class];

I strongly recommend you remove ALL spaces from field and table names as they will cause issues
I also avoid underscores but that's personal preference
 

Shiv

Registered User.
Local time
Today, 12:52
Joined
Dec 23, 2018
Messages
16
The criteria for DLookup is
=DLookup(fieldname, table/query name, filter criteria)

However, don't use a DLookup.
Instead, add the Fare_Table to the query and join by field AVC_Class

Code:
SELECT Table1.[AVC Class]
FROM Table1 INNER JOIN Fare_Table ON Table1.[AVC Class] = Fare_Table.[AVC Class];

I strongly recommend you remove ALL spaces from field and table names as they will cause issues
I also avoid underscores but that's personal preference


i am trying to fetch the result in query 1 through joining but it is not being done therefore i want to get the result in query 1 which i have shown in column 3 and 4 of Table 1.

Please provide the solution and i shall be highly thankful to you for this favour.
 

Attachments

  • Database21.accdb
    896 KB · Views: 71

isladogs

MVP / VIP
Local time
Today, 08:22
Joined
Jan 14, 2017
Messages
18,261
Sorry but I'm not really sure what you are asking
I think you only need one link between the 2 tables:

Code:
SELECT Table1.ID, Fare_Table.[WIM CLass Code], Fare_Table.[AVC Class Code]
FROM Table1 INNER JOIN Fare_Table ON Table1.[AVC Class] = Fare_Table.[AVC Class]
ORDER BY Table1.ID;

I've used an INNER join - see Query1 attached
Query2 was what I posted previously
 

Attachments

  • Database21_v2.zip
    34.6 KB · Views: 69

Users who are viewing this thread

Top Bottom