Convert Excel Sheet to Table

W

Wahab

Hi
Pls. help me to convert my Excel sheet into access Table by writing
recordset. Sheet is some how like this:
Code Kwt Bhn Qtr
USD 0.268 0.377 3.643
BHD 0.710 1.000 9.654
DKK 0.053 0.073 0.717
I want to convert with access table (TblCurrency) in this way:
Country Code Rate
Kwt USD 0.268
Kwt BHD 0.710
Kwt DKK 0.053
Bhn USD 0.377
Bhn BHD 1.000
Bhn DKK 0.073
Qtr USD 3.643
Qtr BHD 9.654
Qtr DKK 0.717
please show me how i will write recordset to convert Excel sheet
thanks
 
J

John W. Vinson

Hi
Pls. help me to convert my Excel sheet into access Table by writing
recordset. Sheet is some how like this:
Code Kwt Bhn Qtr
USD 0.268 0.377 3.643
BHD 0.710 1.000 9.654
DKK 0.053 0.073 0.717
I want to convert with access table (TblCurrency) in this way:
Country Code Rate
Kwt USD 0.268
Kwt BHD 0.710
Kwt DKK 0.053
Bhn USD 0.377
Bhn BHD 1.000
Bhn DKK 0.073
Qtr USD 3.643
Qtr BHD 9.654
Qtr DKK 0.717
please show me how i will write recordset to convert Excel sheet
thanks

No code is needed, or even appropriate. Instead you can use a "Normalizing
Union Query".

Use File... Get External Data... Link to link to your table (well, you can use
code using the TransferSpreadsheet method if that's more convenient). Have
your target tblCurrency already defined. Create a UNION query based on the
linked spreadsheet:

SELECT "Kwt" AS COuntry,
Code:
, [Kwt] AS RATE
FROM linkedspreadsheet
UNION ALL
SELECT "Bhn", [Code], [BHN]
FROM linkedspreadsheet
UNION ALL
SELECT "Qtr", [Code], [Qtr]
FROM linkedspreadsheet;

Add more select clauses if you have more countries.

Base an Append query on this Union query and run it to append the data into
your table.
 
W

Wahab

John W. Vinson said:
Hi
Pls. help me to convert my Excel sheet into access Table by writing
recordset. Sheet is some how like this:
Code Kwt Bhn Qtr
USD 0.268 0.377 3.643
BHD 0.710 1.000 9.654
DKK 0.053 0.073 0.717
I want to convert with access table (TblCurrency) in this way:
Country Code Rate
Kwt USD 0.268
Kwt BHD 0.710
Kwt DKK 0.053
Bhn USD 0.377
Bhn BHD 1.000
Bhn DKK 0.073
Qtr USD 3.643
Qtr BHD 9.654
Qtr DKK 0.717
please show me how i will write recordset to convert Excel sheet
thanks

No code is needed, or even appropriate. Instead you can use a "Normalizing
Union Query".

Use File... Get External Data... Link to link to your table (well, you can use
code using the TransferSpreadsheet method if that's more convenient). Have
your target tblCurrency already defined. Create a UNION query based on the
linked spreadsheet:

SELECT "Kwt" AS COuntry,
Code:
, [Kwt] AS RATE
FROM linkedspreadsheet
UNION ALL
SELECT "Bhn", [Code], [BHN]
FROM linkedspreadsheet
UNION ALL
SELECT "Qtr", [Code], [Qtr]
FROM linkedspreadsheet;

Add more select clauses if you have more countries.

Base an Append query on this Union query and run it to append the data into
your table.[/QUOTE]
Thanks Mr.John
This will not solve my problem, sometime countries are increasing or
decreasing and I have more than 110 countries and currencies and want to
compare the monthly rate form past and current month and feed in system with
correct decimals, slight mistake in entry gives hell of difference. My idea
is to compare both tables and mark only fields which rates are changed, so I
can enter those rates only and minimise the entry mistakes.
For this reason I need to write code which will make my job automatically. I
appreciate if someone will give me how to write codes.
Thanks and regards
 
J

John W. Vinson

This will not solve my problem, sometime countries are increasing or
decreasing and I have more than 110 countries and currencies and want to
compare the monthly rate form past and current month and feed in system with
correct decimals, slight mistake in entry gives hell of difference. My idea
is to compare both tables and mark only fields which rates are changed, so I
can enter those rates only and minimise the entry mistakes.
For this reason I need to write code which will make my job automatically. I
appreciate if someone will give me how to write codes.
Thanks and regards

Well, it would have helped to say so.

You can still link to the spreadsheet and write VBA code to loop through its
Fields collection and construct SQL, or open a recordset based on your actual
table. Perhaps you should start a new thread posting these additional
requirements and the structure of your Access table, so that someone else
could jump in.
 

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