Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 23rd, 2008, 04:26 AM
WhiteLady WhiteLady is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 WhiteLady User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 32 sec
Reputation Power: 0
Importing data from Excel

Hi people!

Can anyone please help me with this problem:

I want to import data from MS Excel which looks like this:

SITE P1 P2 P3
Site1 1 2 3

Into table in Access that would look like this:

SITE P
Site1 1
Site1 2
Site1 3

Help!

Reply With Quote
  #2  
Old April 23rd, 2008, 10:33 AM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 346 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 10 h 29 m 4 sec
Reputation Power: 1
OK there are a couple of options.

First are there just 3 columns or did you just list 3 for the example?

How often do you need to do this. Is it something that happens daily, or is this a one time only, or????

Reply With Quote
  #3  
Old April 23rd, 2008, 02:34 PM
WhiteLady WhiteLady is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 WhiteLady User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 32 sec
Reputation Power: 0
Re: Importing from Excel

The 3 columns were just for example. I will have up to 8 columns is Excel. When I import it to Access I would like to have a table with only 2 colums, for example:

Table in Excel looks like this:

PERSON PET1 PET2 PET3
Person1 Dog Cat Snake
Person2 Hamster
Person3 Bird Dog
...

And I would like for a table in Access to look like this:

PERSON PET
Person1 Dog
Person1 Cat
Person1 Snake
Person2 Hamster
Person3 Bird
Person3 Dog ...

I need this procedure one time only.

P.S. Thank you for your reply




Quote:
Originally Posted by dykebert
OK there are a couple of options.

First are there just 3 columns or did you just list 3 for the example?

How often do you need to do this. Is it something that happens daily, or is this a one time only, or????

Reply With Quote
  #4  
Old April 23rd, 2008, 03:28 PM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 346 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 10 h 29 m 4 sec
Reputation Power: 1
Alright that makes it easier.

First you can't do it as just a simple import. But it's not complicated either.

1. Create a table that has the 2 fields you want.
2. Link or import the excel data
3. Create an insert query like this

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet1
FROM tblImport
WHERE Pet1 <> ""

This will insert the people and their first pet into your new table.

4. modify the query for each other pet/column:

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet2
FROM tblImport
WHERE Pet2 <> ""

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet3
FROM tblImport
WHERE Pet3 <> ""

... etc.

Remember to change the pet/column in BOTH places!

This is a bit brute force, but it's simple and since you only need to do it once it is actually the easiest.

Make sense?

Reply With Quote
  #5  
Old April 23rd, 2008, 03:40 PM
WhiteLady WhiteLady is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 WhiteLady User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 32 sec
Reputation Power: 0
Re: Importing from Excel

Yep - That makes sense!

Thank you very much! I will try this procedure tomorrow and I'll let you know how it went :-)


Quote:
Originally Posted by dykebert
Alright that makes it easier.

First you can't do it as just a simple import. But it's not complicated either.

1. Create a table that has the 2 fields you want.
2. Link or import the excel data
3. Create an insert query like this

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet1
FROM tblImport
WHERE Pet1 <> ""

This will insert the people and their first pet into your new table.

4. modify the query for each other pet/column:

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet2
FROM tblImport
WHERE Pet2 <> ""

INSERT INTO tblPeoplePet (Person, Pet)
SELECT Person, Pet3
FROM tblImport
WHERE Pet3 <> ""

... etc.

Remember to change the pet/column in BOTH places!

This is a bit brute force, but it's simple and since you only need to do it once it is actually the easiest.

Make sense?

Reply With Quote
  #6  
Old April 25th, 2008, 02:33 AM
WhiteLady WhiteLady is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 4 WhiteLady User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 32 sec
Reputation Power: 0
Re

I tried the code and it works smoothly!


Quote:
Originally Posted by WhiteLady
Yep - That makes sense!

Thank you very much! I will try this procedure tomorrow and I'll let you know how it went :-)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Importing data from Excel


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT