Hi,
I was wondering if anyone has any idea how to use a variable as a table name in an SQL query in MS Access. My database creates a table based on a contract number (named after the contract number) and I wish to be able to retrieve info from a table based on the contract number on the form.
contract_no is a dropdown box on the form. It is the name of the table also.
I have gotten this code so far,
SELECT Document_corr2. EE_Ref_no AS [EE Ref#], Document_corr2. Trim_Ref_no AS [Trim Ref#], Document_corr2. Subject, Document_corr2. Correspondence_ from AS [Correspondence]
FROM [contract_no]
ORDER BY Document_corr2. EE_Ref_no;
I don't know how to use the FROM clause to take the dropdown box value as the table name.
thanks for your help
I was wondering if anyone has any idea how to use a variable as a table name in an SQL query in MS Access. My database creates a table based on a contract number (named after the contract number) and I wish to be able to retrieve info from a table based on the contract number on the form.
contract_no is a dropdown box on the form. It is the name of the table also.
I have gotten this code so far,
SELECT Document_corr2. EE_Ref_no AS [EE Ref#], Document_corr2. Trim_Ref_no AS [Trim Ref#], Document_corr2. Subject, Document_corr2. Correspondence_ from AS [Correspondence]
FROM [contract_no]
ORDER BY Document_corr2. EE_Ref_no;
I don't know how to use the FROM clause to take the dropdown box value as the table name.
thanks for your help
Comment