Select Column runtime in query

M

Max

hi is it possible to for query to retrieve the data, by passing column name
run time ?
Eg:

Table Sales, having data like below

Product-2000-2001-2002-2003-2004
x-11000-2000-3000-4000-55444-454155

if i pass runtime "Select <year figure> from tblsales" it should return the
data for product,and the particular yerar pass by.

Thanx
 
D

Dale Fye

Max,

Given the way you presented your data, you can create a SQL string in VBA
code, then run the query. But I think you have a bigger problem in that your
data looks like a spreadsheet, rather than a relational database. In a
relational database, I would store the data you showed in three columns:

Product SalesYear SalesAmount
x 2000 11,000
x 2001 2,000
x 2002 3,000

Then you could query your table like:

SELECT Product, SalesAmount
FROM yourTAble
WHERE SalesYear = 2000

HTH
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top