Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    one2this is offline Novice
    Windows 11 Office 365
    Join Date
    May 2023
    Posts
    5

    Multiple mdb Files

    Hi,

    Just wondering if anyone can assist in helping me extract data from multiple .mdb tables of different files names but each contain a table that has same name (accessories). I would ideally like to extract these to a separate table.



    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Are you saying you cannot open the mdbs yourself, or looking for code to do it?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    one2this is offline Novice
    Windows 11 Office 365
    Join Date
    May 2023
    Posts
    5
    Hiya, thanks for reply. I am looking for code to do this please?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I have none.
    However Google is always my first point of call.
    https://www.google.com/search?q=link...hrome&ie=UTF-8

    From that I found the first link https://p2p.wrox.com/access/32446-ma...ess%20database.

    I would use that code with a DIR() for getting each file in turn in your folder.
    Then run a query on that linked table to populate your table, perhaps with an extra field to indicate where the data came from, if you need to know that.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Why not just use the linked table manager to link the tables in one common database and run a make table query once? If editing/appending is required on the new table afterwards, have separate queries for that. The original post is kind of vague as to what's going on, so I might be missing something.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    one2this is offline Novice
    Windows 11 Office 365
    Join Date
    May 2023
    Posts
    5
    Hi, Sorry I think you have misunderstood. I have numerous mdb files that are stored in folders by month. e.g. File Name 001.mdb, File Name 002.mdb etc in January Folder and File Name 0023.mdb, File Name 0024.mdb etc in February. Within each of these files is a table called Accessories which has numerous records in each. What I need is to be able to extract this data automatically based on a selected date range and output it to a table, query or report?

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    I understood. However if the number of files/tables is large, then while that could still work, you might be wanting some other type of automated solution. I think the big problem is that the data is split up into so many files, which may be somewhat normal for Excel workbooks, not so much for relational databases. Unless a back end db that would hold all this data encroaches the 2 GB limit, then I see no reason to split it all up based on dates. Anything you do to get around that issue would be a hack, and I'd rather devote time to practical solutions. I'm confident you'll get someone to help you with that since a couple of usual responders here tend to do that sort of thing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    in VBA you can write a query along the lines of

    dim fpathandname as string
    dim sqlstr as string

    sqlstr="SELECT * FROM accessories IN '" fpathandname & "'"

    Note this is the select query, you haven't said what 'extract data' means, but can be converted to a maketable or append query or applied to a querydef to open as a query or as a recordsource to a report

    you will need your own code to calculate fpathandname - might be something like

    fpathandname ="C:\January" & "001" & ".mdb"

    but depends on what 'a selected date range' means and how you determine what dates are in file 001 etc

    If you need multiple files for a month, modify the above to be a union query

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Here's a start. A db to list all MDB files in a folder (with subfolders option)
    The results are displayed in an extended listbox, pending additional code to process the MDBs selected.

    one2-davegri-v01.zip

    Click image for larger version. 

Name:	SEARCH.png 
Views:	32 
Size:	77.3 KB 
ID:	50289

  10. #10
    one2this is offline Novice
    Windows 11 Office 365
    Join Date
    May 2023
    Posts
    5
    Davegri, Thanks very much, yes that initial bit lets me drill down into all subfolders to list all mdbs. Is there a way to select within each of these mdbs listed the accessories table within them? Please note there is a global table that contains Job Number and Date Range that links into these but the accessories within each of these jobs is qithin a standalone mdb file called accessories?

  11. #11
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Please take into consideration that I know nothing of your database(s) or their internal and external relationships and nothing at all of their table structure.
    Perhaps an explanation of those concepts and an idea of how the db you are attempting to develop fits into the overall picture. An image of table relationships would be essential.

    Is there a way to select within each of these mdbs listed the accessories table within them?
    Selected how? To what end? After 'Selected' what happens? Do you simply mean add code to restrict the listbox to only MDBs that contain a table named accessories?

    Please note there is a global table that contains Job Number and Date Range that links into these but the accessories within each of these jobs is within a standalone mdb file called accessories?
    What are jobs? Where is the global table? In a db named accessories.mdb?
    What db would contain the code I supplied in post#9?

  12. #12
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    How many backends are there? How many years worth? How big is each file?
    Never a good idea to save backends AS data (ie.months)
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    one2this,
    In #11 davegri makes excellent points showing that readers are basically guessing the issue and offering advice.

    We know so little of you, your environment, your business....
    Perhaps you could step back and describe the situation in detail. A starting point may be along this scenario.
    Suppose you had to give this "problem/opportunity/project" to a hired contractor/developer. What would be the requirement(s) for such?
    That's what readers are facing -- no complete picture of the issue in context of you, your environment, business, priority etc.

  14. #14
    one2this is offline Novice
    Windows 11 Office 365
    Join Date
    May 2023
    Posts
    5
    Hi,


    Apologies for not properly explaining the issue


    Basically here is scenario.


    There is a global table that stores basic job details. Eg Customer Name, Reference, Job Number and Production Date, Delivery Date etc.


    From manufacturing software it then generates an individual mdb file which contains all the specific Job Details within numerous tables (including Prices, Accessories, Manufacturing Sizes etc)


    For every job generated it creates an mdb file and populates it into a year / month folder on Server.


    What I require it to be able to extract accessories from within a Table in these individual mdb files based on a delivery date that is held on the global table.


    I can of course do it individually but that is of no use when there are numerous jobs each day / week.

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Break it down into steps.
    Get a list of the files or process one at a time. You have already been given code for that step.
    Link to each db in turn.
    Run query to obtain data.

    Start with a hard coded file to check it works, then add code to find one file, then add loop for each file in folder.
    You will need to account for what has already been processed and what has not as well.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-10-2019, 11:39 AM
  2. Replies: 8
    Last Post: 06-24-2015, 08:22 AM
  3. Merging multiple mdb files into one
    By Swoosh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 12:01 PM
  4. Replies: 4
    Last Post: 06-14-2011, 07:19 PM
  5. Replies: 2
    Last Post: 05-25-2010, 02:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums