G
Guest
Dear Access gurus,
We have an Access database that contains tables that get their data from
another financial system. We are creating a query which needs to link two
tables together. However, although they contain some similar information,
they don't have a primary key linking them to enable them to "talk together"
(and there are no intermediary tables to help achieve this either).
The issue we have is that in the 1st table (CTRONADM_AP_VOUCHERS) it
contains a VOUCHER_ID field of 9 digits (eg. 000000092), and in the 2nd table
(CTRONADM_QUEUE_DATA) it contains a OBJ_ID field of 12 digits (eg.
001000000092). These two fields need to link (as they are the only fields
that directly relate) but as they have different string lengths they won't!
The 1st field of 9 characters should match up with the last 9 characters of
the 2nd field (eg. it should ignore the first 3 characters which represent
the organisation code).
Someone from our finance software company has suggested we use a Mid
function to achieve this (but provided no other information). Although we
can understand how a mid function could extract the 9 characters using a
calculated field in a query, we're not sure how to use this to enable linking
of the tables to extract relevant data between the two tables.
Do we need to use an SQL command to achieve this, and if so, what would we
need to write in SQL to extract the relevant data and/or achieve a link
between the two tables? At present our SQL query code looks like this:
SELECT CTRONADM_QUEUE_DATA.QUEUE_ID, CTRONADM_QUEUE_DATA.USER_ID,
CTRONADM_QUEUE_DATA.CREATE_DATE, Now() AS Expr1,
DateDiff("d",CTRONADM_QUEUE_DATA.CREATE_DATE,[Expr1]) AS Expr2,
CTRONADM_WFPO_APPROVER_CODE.LONG_DESCRIPTION, CTRONADM_OBJECT_DATA.OBJ_ID,
CTRONADM_AP_VOUCHERS.VOUCHER_ID
FROM CTRONADM_AP_VOUCHERS, CTRONADM_OBJECT_DATA INNER JOIN
(CTRONADM_QUEUE_DATA INNER JOIN CTRONADM_WFPO_APPROVER_CODE ON
CTRONADM_QUEUE_DATA.USER_ID = CTRONADM_WFPO_APPROVER_CODE.CODE_ID) ON
CTRONADM_OBJECT_DATA.WF_ID = CTRONADM_QUEUE_DATA.WF_ID
WHERE (((CTRONADM_QUEUE_DATA.QUEUE_ID)="APRVVOU"));
Any assistance would be greatly appreciated
Regards
JD2
We have an Access database that contains tables that get their data from
another financial system. We are creating a query which needs to link two
tables together. However, although they contain some similar information,
they don't have a primary key linking them to enable them to "talk together"
(and there are no intermediary tables to help achieve this either).
The issue we have is that in the 1st table (CTRONADM_AP_VOUCHERS) it
contains a VOUCHER_ID field of 9 digits (eg. 000000092), and in the 2nd table
(CTRONADM_QUEUE_DATA) it contains a OBJ_ID field of 12 digits (eg.
001000000092). These two fields need to link (as they are the only fields
that directly relate) but as they have different string lengths they won't!
The 1st field of 9 characters should match up with the last 9 characters of
the 2nd field (eg. it should ignore the first 3 characters which represent
the organisation code).
Someone from our finance software company has suggested we use a Mid
function to achieve this (but provided no other information). Although we
can understand how a mid function could extract the 9 characters using a
calculated field in a query, we're not sure how to use this to enable linking
of the tables to extract relevant data between the two tables.
Do we need to use an SQL command to achieve this, and if so, what would we
need to write in SQL to extract the relevant data and/or achieve a link
between the two tables? At present our SQL query code looks like this:
SELECT CTRONADM_QUEUE_DATA.QUEUE_ID, CTRONADM_QUEUE_DATA.USER_ID,
CTRONADM_QUEUE_DATA.CREATE_DATE, Now() AS Expr1,
DateDiff("d",CTRONADM_QUEUE_DATA.CREATE_DATE,[Expr1]) AS Expr2,
CTRONADM_WFPO_APPROVER_CODE.LONG_DESCRIPTION, CTRONADM_OBJECT_DATA.OBJ_ID,
CTRONADM_AP_VOUCHERS.VOUCHER_ID
FROM CTRONADM_AP_VOUCHERS, CTRONADM_OBJECT_DATA INNER JOIN
(CTRONADM_QUEUE_DATA INNER JOIN CTRONADM_WFPO_APPROVER_CODE ON
CTRONADM_QUEUE_DATA.USER_ID = CTRONADM_WFPO_APPROVER_CODE.CODE_ID) ON
CTRONADM_OBJECT_DATA.WF_ID = CTRONADM_QUEUE_DATA.WF_ID
WHERE (((CTRONADM_QUEUE_DATA.QUEUE_ID)="APRVVOU"));
Any assistance would be greatly appreciated
Regards
JD2