How to create a flatfile from a series of tables in Access? - ms-access

I have a series of tables in an Access 2007 database. I am trying to find a way of outputting a flat-file to an excel spreadsheet that combines all of the tables so that each row of the flatfile represents a unique combination of the table rows from each table.
For example, these tables:
Would combine to make this output table:
The challenges I'm facing are:
The 'input' tables can vary in number of rows and columns, as well as quantity
The total number of rows in the final output table can get quite large (200,000+ rows)
I know Excel and VBA (in Excel) well but almost nothing about Access
Is there a way to do this in Access? Is there some native functionality in Access that I'm completely overlooking? Any pointers (even if it's "you need to read into X and Y") would be greatly appreciated!
Thanks,
Adam

As noted above:
Create a new query. Select your 3 tables as the data sources. If desired, set up joins between tables by dragging a line between a field in one table to a field in another. Without joins you will get a Cartesian Product ... every from 1st table paired with every row of 2nd table, and then each of those combination paired with every row of 3rd table. Select the fields you want included in the result set. When the query returns what you need, save it and give it a name. Then you can export that named query to Excel.
If the table is large, you could hit Excel's row / column limit though.

Related

How can I create a table that uses an equation to average data from another table?

I have a table that contains data from repeated experiments (for example, site A has one sample, and the lab processed the sample three times obtaining slightly different values). I need to average these results in a separate table, but what I have read on the Microsoft support site is that a query that pulls data into another table with a calculated field is not possible on Access.
Can I query multiple data points from one table into a single calculated field in another table? Thank you.
UPDATE
I ended up doing a lot of manual adjustments of the file format to create a calculated field in the existing table that averages each sites data, so my problem is, for my current purposes, solved. However I would still like to understand. Following up with you both, I think the problem was that I had repeated non-unique IDs between rows when I probably should have made data columns with unique variable names so that I could query each variable name for an average.
So, instead of putting each site separately on the y axis, I formatted it by putting the sample number for each site on the x-axis:
I was able to at least create a calculated field using this second format in order to create an average value for each site.
Would have there been a way to write a query using the first method? Luckily, my data set was not at all very hefty, so I could handle a reformat manually, but if the case were with thousands of data entries, I couldn't have done that.
Also, here is the link to the site I mentioned originally https://support.office.com/en-ie/article/add-a-calculated-field-to-a-table-14a60733-2580-48c2-b402-6de54fafbde3.
Thanks all.

SUM function needs automatically to adjust for changes to SQL DB entries

I'm using multiple Calc tables in a single document for ingoing and outgoing bills that are stored in a SQL DB. Table A has ingoing bills and Table B has outgoing bills. For example table A has data from B2-B39 and table B has data from B2-B15. I need the sum function to automatically adjust when data entries are added or subtracted.
I can use =SUM(B2:B39) in tableA.B40 and =SUM(B2:B15) in tableB.B16 to get the sums of the current data, at the end of the data entries. However, when the DB changes, for example Table A has data from B2-B44, I end up missing five entries. To further complicate things, I have Table C, where I evaluate the net income. For example in Table C I use tableB.B16-tableA.B40. When the number of entries in tables A and B change the function in Table C no longer works.
I need SUM in multiple tables to automatically adjust its position based on how many rows of data are found in the DB.
Maybe there is something about your layout that you have not mentioned but a solution would seem to be to apply whole column references (eg =SUM(B:B)), or if you must have the total in the same column move it to the top and sum like so:
=SUM(B2:B1048576)
Otherwise try something like LibreOffice Basic and search for the first empty cell in the column to put the formula in.

Import excel records into access based on column value

I am a newbie with access and I am trying to import records into several tables from an excel file. Each row in excel has different number of columns, but the good thing is column A is able to help me to identify what records need to go to my different tables.
Sample table
As you can see in the picture, Row 1 Column A has the value of "H", which would indicate that this record needs to go to the "H" table. Then the next few rows have a value of "R" in Column A which indicates that these records should go to the "R" table, and so on and so forth. However, the number of records to be imported into each table will vary all the time. Like the sample above rows 2 through 10 belong to the table R, but the next import may have only 5 or 20 records.
Currently I am using a temporary table and using an append query for each table but I am wondering if there is an easier way via VBA or other method that could be faster and more efficient.
Thanks!
The way you are doing it now may be the best way. An alternative would be to do this in two steps:
1) split your column A, and parse out to different sheets (or different workbooks).
http://www.rondebruin.nl/win/s3/win006.htm
2) load those different sheets (or workbooks) into different tables.
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm#ImpAllWktsSepTbl
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm#ImpFldWrkFiles

MS Access Query: Creating a Master table from premade query that selects records with most recent date

I'm trying to make a master table in ms access that constantly updates the records of the unique model numbers based upon the most recent date.
The premade table was created by using a select query that brings all the records of multiple tables and inserts them into a single table. Within each table there are multiple fields however the only relevant fields are the Model number field and the Date. Across the tables the unique model numbers are repeated, but their individual time stamps are different.
I need the master table to select the records with the most recent date and place the whole record into the master table. I'm new to ms access and I don't know how I could do this. Any tips of suggestions would be most appreciated.
If you would need such a table then I'd say there's definitely something wrong with your database design.
Having said that, why don't you query on the most recent date of tables that hold Model Numbers?
It might help if you could elaborate on why you'd want to do this, as in why you have multiple tables that hold Model Numbers.
Maybe your current database design is open for improvement.
Kind regards,
Rene

Getting the value present in table 1 to table2

I am trying to develop a report having two tables with one single data set.each table is filtered with the user giving a date parameter. is there any way that I can get the value present in a text of table1 into the table 2.
If you have a report with two table objects in it, both of which point at the same dataset, then all of the data in either table will be available in the other table - the only reason that one value would be available in one table but not the other is if the tables have different filter conditions. Therefore, you may need to amend the filter conditions.