+ Reply to Thread
Results 1 to 29 of 29

Extract contents of table columns

  1. #1
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Smile Extract contents of table columns

    We are going over to ordering products using the manfacturer's EDI system but we have a problem incorporating certain product codes that we sell.

    Background:-
    We sell products either as a single entity or in a kit that comprises that and other products. Eg, we sell a Car Cleaning set that comprises a sponge, a wheel cleaning brush and a leather. We give this kit our own product code (MUK80 as an example) which is what the customer orders when he buys.

    All those component parts are also sold as single items, using the manufacturer's product code.

    We reorder stock daily based on a query that extracts the product codes and quantities from the daily sales invoices. Amongst these codes are of course the kits, but as the manufacturer doesn't recognise these codes we can't include these on the EDI order.

    We have the list of these kits contained in a table; col 1 is the kit product code and the other columns separately contain the consist part codes and quantity of each consist. A kit can have anything up to 6 consists. So the table consists of 13 Cols. At this time we have 130 different kits and increasing.

    What I need to do is to be able to extract the consist parts of the kits sold and add these to the order list. This list may already have some of the parts on there as they could also have been sold as a single item.

    To give an example of this, let's say we sell 3 of the MUK80 Car cleaning kits; The MUK80 will appear on the reorder query, but what I need is to able to get the consist parts of that kit added to the list, which let's say may already include 2 sponges and one brush that have been sold independently.

    If necessary, I can get the existing reorder query to ignore the MUK products and I can write another query to capture these.

    The trick I'm missing is how to get those consist parts onto the final reorder. We have a macro that exports this order as a csv file that we then convert to xml outside of access.

    I would really appreciate any help on this - a query would be my preferred option ( I'm none too bright using VBA) but I'm up for the challenge should it be necessary.

    Sorry for the longwinded post, but I thought a detailed explanation may help frame the problem.

    Thanks in anticipation....
    Mike
    Last edited by MikeWaring; 11-27-2010 at 10:35 AM. Reason: correct typos

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Mike, it would be really helpful if you posted your database with a limited amount of sample data. It would then be easier to review, analyze and make a recommendation.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Hi Alan, thanks for the reply. I'll create a copy of the database and put some dummy data in there.
    I'm actually still developing it as we speak with "live" data from previous customer orders so I may need to do some more data input to the tables that I think you'll be looking at.
    At the moment the db is around 16mb; I don't know what it will be when I take most of the data out (I suspect not much smaller as the structure is fairly large and still growing) - I don't want to start deleting queries or other objects unless necessary, as it may make the db unstable or stop some processes running correctly. Is there a max size that I can send?
    Rgds
    Mike

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    There is a size limitation set by the board. Before you try to upload the db, make sure that you compact and repair. That will reduce the size. Also, you have to zip any db posted to the board.

  5. #5
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Quote Originally Posted by alansidman View Post
    There is a size limitation set by the board. Before you try to upload the db, make sure that you compact and repair. That will reduce the size. Also, you have to zip any db posted to the board.
    Hi Alan, I've copied the database and populated it with some test data. The tables that contain the relevant info are as follows:-
    "Import data From Ebay - MIDS TOOLS". This is the table that is imported and overwritten every day and contains details of that day's despatches.

    "MUK part consists" This is a permanent table that holds the consist parts of the kits.

    "Products Main Import Table" This a permanent table that holds details of our products.

    The following queries draw info from those tables:-
    "Toolstream "MUK" PRODUCT CONSISTS" This is a dynaset of all the MUK kits sold that day and includes the consists. The Consist qtys aren't summed (i.e. they only show the consist qty for each single kit, not the total consists sold)

    "Toolstream Product order with prices" This query produces the re-order report that shows what items we have sold that day. This is where the problem lies. You will see the reorder list shows the "MUK" numbers at the kit level; what I need is for the consist parts to be on that list as these are the products that we order from the supplier.

    If on the same list there are already some of the consists part #s by virtue of the fact that we have also sold these as single items, the product number should only appear once but the qty should be the sum of that product sold in the kits plus those sold as a single product. Eg, product # 427655 - 1 sold as part of kit MUK04 and 2 sold as individual items so the re-order qty for that should be 3.

    "PRODUCT REORDER csv file for Toolstream EDI" This is essentially the same as the above qery, but this is the file that we send to the supplier's EDI system. Ditto the above re the consist parts being on this report and not the MUK kit numbers.

    I've also entered some products in the test data that have been sold in their own right as well as appearing as part of the MUK kits that have been sold. If you need me to send a breakdown of what the final re-order reports should contain based on the day's sales, I can do this, but I don't want to clog up this post with too much info.
    Thanks & rgds
    Mike

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Mike;
    You forgot to upload the file.

    Alan

  7. #7
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Quote Originally Posted by alansidman View Post
    Mike;
    You forgot to upload the file.

    Alan
    Hi Alan, I did the attachment, but don't know why it didn't go with the reply. I tried again just now and I kept getting a "Excel Forum" error so I stripped all objects out of the db that aren't relevant to this topic. It seems to have worked now.

    Thanks for letting me know.
    Rgds
    Mike
    Attached Files Attached Files

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Mike;
    I was able to add the consist part numbers to your query by doing a left join on the Kit. I think however, you will continue to have issues as your MUK Part consists table is not normalized. You would be better served to change the table early to One to many relationship with the product label in your Import .... table.

    I would set up the MUK Part Consists table as follows
    PID --PK
    ProductCode -- FK
    Supplier
    EachWeightKG
    Consist
    ConsistQty

    Then for each ProductCode, you will have many part numbers (Consist), one to many relationship. This will make your queries easier.

    Alan
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Hi Alan, thanks for your continued help. I know how to physically make the relationships, but this aspect is still somewhat of a dark art to my level of knowledge. I'm still getting my head around this...

    I'll set the table up as you suggest; on the first 2 field names you have put PK and FK respectively - what do these refer to?
    Sorry for the extra questions....
    Kind rgds
    Mike

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Quote Originally Posted by MikeWaring View Post
    Hi Alan, thanks for your continued help. I know how to physically make the relationships, but this aspect is still somewhat of a dark art to my level of knowledge. I'm still getting my head around this...

    I'll set the table up as you suggest; on the first 2 field names you have put PK and FK respectively - what do these refer to?
    Sorry for the extra questions....
    Kind rgds
    Mike
    PK--Primary Key--A unique key for every record in your table. It is used to keep records straight
    FK--Foreign Key--this will be the key that equates to another key in another table, to allow matching of relationships.

    http://www.databasedev.co.uk/primary_foreign_keys.html

    There is a very good primer on database relationships in this thread. I urge you to read it. It is filled with valuable information on building a db.

    http://forums.aspfree.com/microsoft-...es-208217.html

    Alan
    Last edited by alansidman; 11-30-2010 at 04:56 PM.

  11. #11
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Hi Alan, thanks for the further info.
    Did you modify the query to get it to work? I've just looked at the database but the query results appear the same.

    But now I have another issue - I can't open the db as I'm getting a security error. I've tried copying the db to my C drive as instructed in the error but still no good.

    On your recommendation re setting the table up, do I need to make the PID field an Autonumber? I looked at the links you provided and it seems that this is the best way to get a PK. I thought the actual productnumber field could be used for this, but you suggest this as the FK.

    Again, thank you for your continued support.
    Rgds
    Mike

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Mike:
    Did you modify the query to get it to work? I've just looked at the database but the query results appear the same.
    Yes, I changed the structure slightly to the query. I added the MUK Parts consist table to the query and did a left join on the "import data from ebay...." table.
    But now I have another issue - I can't open the db as I'm getting a security error. I've tried copying the db to my C drive as instructed in the error but still no good.
    Try a right click on the data base before opening it and selecting properties. There may be a check box that needs to be unchecked. Can't recall the name, but I have had this issue with db downloaded from forums in the past.
    On your recommendation re setting the table up, do I need to make the PID field an Autonumber? I looked at the links you provided and it seems that this is the best way to get a PK. I thought the actual productnumber field could be used for this, but you suggest this as the FK.
    I always make it a practice to make the id for the table an autonumber. I then use any other identifier as a secondary key that is matched to a FK in other tables. It is a good practice.

    Alan

  13. #13
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Hi Alan, thanks for the further help. Sorry for the delay in responding but I've been away for a few days.

    I'll try your suggestions, but please excuse me re implementing it; I'm like a piano player that can't read music - I can usually get soemthing done by example but reading it from text doesn't always sink in...
    Kind regards
    Mike

  14. #14
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Extract contents of table columns

    Quote Originally Posted by alansidman View Post
    Mike:

    Yes, I changed the structure slightly to the query. I added the MUK Parts consist table to the query and did a left join on the "import data from ebay...." table.

    Try a right click on the data base before opening it and selecting properties. There may be a check box that needs to be unchecked. Can't recall the name, but I have had this issue with db downloaded from forums in the past.

    I always make it a practice to make the id for the table an autonumber. I then use any other identifier as a secondary key that is matched to a FK in other tables. It is a good practice.

    Alan
    Hi Alan, I just tried the query and it's nearly there; however what I need for the EDI to work is to have the consist code numbers of the respective "MUK" code appear in the "Reorder Product Code" field of the query - at the moment the "MUK" numbers are still showing instead.

    The Supplier EDI output csv file will only have 2 columns - the "Reorder Product Code" and the "sumof quantity" As the "MUK" numbers are our creation, the supplier doesn't recognise these, only the consist parts.

    Is it possible to do what I'm asking?
    Kind rgds
    Mike

  15. #15
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Amy;
    Your issue is that your database is not normalized. In trying to convert your table layout, is this an attempt to normalize the database or is there something else you are attempting to do?

    Alan

  16. #16
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Amy;
    Attached is a solution for you. Here is what I did. I created three individual queries to get your data in the format you requested for each month. They need to be done month by month. Then I did a Union query to merge the three queries.

    If you are looking to do anything with this information in the future, I would suggest you take the last query (4) and do a make table query and then use the new table which is in a normalized fashion for future queries.

    Alan
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Hi Alan,

    Sorry, I don't know what normalized means? I have an excel table that has months across the top as column headers, and style numbers down the left side as row headers, and then the inside is all the units we are forecasting for sales.

    I need to combine multiple excel tables and do various calculations, like calculate dollar values using wholesale prices for each style.

    My approach is to import that excel tables into Access where I can combine them easier. I also need to do a bunch of calculations. Like add some forecasts together,but subtract forecasts for units that are returned in each style/month. So I thought if I can get a spreadsheet that has two years of forecast months (24 columns) into a list that is very long but just has 3 columns (style, monthyear, units) it will be easier to do my calculations.

    Otherwise I have to create multiple columns to calculate the dollar value of each month's units. So a column for January dollars (Jan units x price), then a column for Feb dollars (Feb units x price)....... If I have this simple list, it's just one column (monthyear units x price). Then I can pivot table to get things back with months across the top row.

    Does this help you understand what I am trying to do?

    It seems from my research so far it will be a complicated program to convert the tables to this 3 column format. Maybe I should just give up and import all my forecast tables into Access the way they are and figure out how to work with it there?

    I'm a basic Excel user, good with pivot tables and can write very simple macros, but that's it so far.

    Thanks, Amy

  18. #18
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Hi Alan, I just found that you had already replied with a solution. I will try it and see how it works. Somehow I had read a post where you had asked me a question before I found this response with your file. Sorry, I'm very new to threads and posts and things, but kind of fun and MANY THANKS for such a prompt response! Amy

  19. #19
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Hi Alan,

    I am so excited! Thank you so much for your help. I downloaded your access file and it worked perfectly. I have never used the Excel Help Forum (or any help forum) before and can't believe I was able to find a solution to my problem between when I left work last night and this morning when I arrived. So awesome!

    Thank you! Amy

  20. #20
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    You are welcome.
    Alan

  21. #21
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Alan,

    I've worked with you access solution and figured out how to add a query for another month (April). I can even make the data in the month column say "1/1/2011" instead of Jan (so I can sort better later).

    What I can't figure out is how to adapt the solution to my real database which actually has field headers that are dates in stead of Jan, Feb, Mar. My field headers are 1/1/2011, 2/1/2011, 3/1/2011. I can create the individual queries, but I can't modify the UNION code.

    SELECT Table1.Style, "1/1/2010" AS [Month], Table1.Jan AS Units
    FROM Table1;

    I'm having trouble with the last half of it - when I change Table1.Jan to Table1.1/1/2010 then I get an error message about having incorrect symbols when I try to run it.

    Would you mind helping me adapt the UNION query to work with a table that has dates for field headers? I created one and tried to upload it but it said invalid file, and believe it or not, I don't know how to zip it to be smaller if that is the problem.

    Anyway, this would be very helpful. I've spent about 45 minutes so far and just can't figure it out.

    Thanks, Amy

  22. #22
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Actually I think I have successfully zipped the file, where I added Table2 with my dates as field headers. I hope this makes it easier for you to respond. THANKS! Amy
    Attached Files Attached Files

  23. #23
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    I haven't opened your file yet, but what I did notice is the field names you have, ie. 1/1/2010. This is your problem. Access has a list of reserved names and symbols. You cannot use the slash "/" in a field name.

    If you go to this website you will see a list of reserved names and symbols that cannot be used in field names. You will have to change the field names

    http://support.microsoft.com/kb/209187

    I will look at your file also but I have to move to my other PC as this one is still on Office XP.

    Alan

  24. #24
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Okay, thanks. What is your recommendation for the format of the field names so they can be sorted? I have two years of data, so I can't just use 1, 2,3, it needs to be 1_2010, 2_2011, etc or something. My goal is for the fields to be sortable in pivot tables so the reports come out with the proper month order.

    I just discovered that my 1/1/10 and 2/1/10 field names don't sort properly for some reason, so I definitely need an alternative.

    Thanks!

  25. #25
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    How about renaming the fields "2011 1", "2011 2", etc. Do you think that will work. Avoid using any characters. Maybe even 20111, 20112, then this will be sequential

  26. #26
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Hi Alan,

    I finally figured out that my field headings can be text names like Jan10, Feb10 and when I do the query that combines the monthly files, I can make the data in the month column be whatever I want. When I use 01-11 and 02-11 there, the result will sort properly in a pivot table.

    So I'm down to what I hope is a final question. You mentioned I should take the query that combines the months and make a table. If this query was a regular query, I know how to do it. But it seems that this query is a SQL query, and I don't know how to make it generate a table. Any clues? Thanks, Amy

  27. #27
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Hey again. I think I'm in good shape. I just don't know how to make a table out of the results of the UNION query. I can export it to excel and then import it again, but I'm sure there is a better way.

    I used the help function and it explained how to do it for a regular query, but I think this UNION query is a SQL thing, so when I open in design view I do not see an option to make table....

    Thanks for all of your help. I am well on my way with my project thanks to you. This final thing would be awesome. Amy

  28. #28
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Extract contents of table columns

    Create a new select query and use the Union Query as your record source. Now that you have the select query. Save it. Now, make it a MakeTable Query.

    Alan

  29. #29
    Registered User
    Join Date
    02-16-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Extract contents of table columns

    Thanks, that worked perfectly! I'm all set. Have a great day. Amy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1