473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Importing Data from many Databases into one

Hi everyone, I am trying to get some specific values from a set of access databases, there is a file, within this file there are more than 100 folders, each folder contains 2 databases from which I am willing to import only 2 tables from one and 2 tables from the other, all 100 folders contain the same database structure only a different ID nr.
Until now I have been able to loop through the files and filter if the value on Field "F22" is "JA". Now I want to get the values from specific columns and loop these until there are no more values and continue with the next database.

Hope u understand what I mean, i am not a programmer and this is my first time working with VBA


Expand|Select|Wrap|Line Numbers
  1. Sub LoopThroughFilePaths()
  2.     Dim myArr
  3.     Dim i As Long
  4.     Dim j As Long
  5.     Dim MyFile As String
  6.     Dim Tablename As String
  7.     Dim Table1 As String
  8.     Dim Table2 As String
  9.     Dim Aktdb As DAO.Database
  10.     Dim AktVdb As DAO.Database
  11.     Dim AktRow
  12.     Dim rs1 As Recordset
  13.     Dim rs2 As Recordset
  14.     Dim Bez1 As Recordset
  15.     Dim Bez2 As Recordset
  16.     Dim strFeld As String
  17.     Dim intFeldPos As Integer
  18.     Const strPath As String = "C:\PATH..."
  19.     Table1 = "_Ist1"
  20.     Table2 = "_Ist2"
  21.     Counter = 0
  22.     myArr = GetSubFolders(strPath)
  23.         For j = 1 To UBound(myArr)
  24.             MyFile = Dir(myArr(j) & "\*.mdb")
  25.             'In myFile is the.mdb
  26.             Tablename = Replace(MyFile, ".mdb", "")
  27.             Set Aktdb = OpenDatabase(strPath + Tablename + "\" + MyFile)
  28.             Set AktVdb = OpenDatabase(strPath + Tablename + "\V" + MyFile)
  29.             Set rs1 = Aktdb.OpenRecordset("Ist1", dbOpenDynaset)
  30.             Set rs2 = Aktdb.OpenRecordset("Ist2", dbOpenDynaset)
  31.             Set Bez1 = AktVdb.OpenRecordset("Bez1", dbOpenDynaset)
  32.             Set Bez2 = AktVdb.OpenRecordset("Bez2", dbOpenDynaset)
  33.             Do While Not rs1.EOF
  34.                 strFeld = rs1![F22]
  35.                 intFeldPos = InStr(strFeld, "Ja")
  36.                 If intFeldPos > 0 Then
  37.                     strFeld = Replace(strFeld, " ", "")
  38.                     'MsgBox "Found"
  39.                 Else
  40.                     intFeldPos = InStr(strFeld, "Nein")
  41.                     If intFeldPos > 0 Then
  42.                      strFeld = Replace(strFeld, " ", "")
  43.                      'MsgBox "notfound"
  44.                      Exit Sub
  45.                 End If
  46.                 End If
  47.                 If strFeld = "Ja" Then
  48.  
  49.  
  50.  
  51.  
  52.                 End If
  53.                 rs1.MoveNext
  54.             Loop
Jul 24 '14 #1
4 1060
jimatqsi
1,271 Expert 1GB
"Now I want to get the values from specific columns and loop these until there are no more values and continue with the next database. Hope u understand what I mean,"

No, I don't understand what you mean. What does "loop these" mean? You already have the looping through the rows down okay.

What are the "specific columns" you are interested in? What do you want to do with them?

Also,
Expand|Select|Wrap|Line Numbers
  1. For j = 1 To UBound(myArr)
should be
Expand|Select|Wrap|Line Numbers
  1. For j = 0 To UBound(myArr)-1
because the first element of an array is (0) unless you declare it differently.

Please use the [Code/] button to put any vba code in between Code tags for easier reading.

Jim
Jul 24 '14 #2
Hi thanx for the reply, the specific columns are in Database1(Aktdb): table Ist1 F1-F22, from table Ist2 column f51-f64
and Database2(AktVdb): from Table Bez1 F1-F22 and Bez2 Column F51-F64
I want to have all the information read from those folders merged into one only database having a table pro folder
Jul 24 '14 #3
jimatqsi
1,271 Expert 1GB
It's not very clear to me what exactly you want. But the way to move data from one recordset to another is like this:
Expand|Select|Wrap|Line Numbers
  1. rs1.edit
  2.     rs1!fieldname = rs2!fieldname
  3.     rs1!fieldname2 = rs2!fieldnamewhatever
  4.     ....
  5. rs1.update
  6.  
Jim
Jul 24 '14 #4
Thank you! I will try to make it work, I'll keep you posted.
Jul 24 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Greg | last post by:
Hello, I've to manage many 'table' (having same scheme) on the same server. And I ask myself what could be the best to do (and if you know, why) : Creating as many database (the name would...
1
by: Matthias HALDIMANN | last post by:
When importing data into MS SQL Server 2000 from a MyODBC (v3.51) data source using Data Transformation Services, special characters like öäüéàè are not imported correctly. However, when the MyODBC...
4
by: mike | last post by:
Hi, I am trying to determine what the overhead is per database in SQL Server 2000 Standard. I have the option to put several customers in one database, or give each customer their own database....
0
by: James Moe | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I have an old-ish Sybase dbms (SQL Anywhere v5.x) that does not offer a DUMP command. The only way to extract data is to SELECT all of it,...
4
by: Dirk Olbertz | last post by:
Hi there, I'm currently about to redesign a database which you could compare with a database for managing a library. Now this solution will not only manage one library, but 100 to 500 of them....
7
by: jnikle | last post by:
I have a database in A2003 format that's giving me this error, but it's not the same situation I've been reading about on here. In my development copy, I have imported copies of the backend's...
3
by: Sam Alexander | last post by:
Hi Everone, I'm writing a script to import data from an XML file, and this tutorial is really an awesome guide : http://www.kbalertz.com/Q316005/Import.Server.Component.aspx ... problem though...
2
by: Mike Collins | last post by:
I am importing a XML file and have not been having the best of luck in doing this, but I do have the following solution below. I will not be importing more than 2000 records at a time, but will be...
2
by: ScardyBob | last post by:
Hello, I am having trouble importing data from an Excel Worksheet. When I try to import the data, everything works except certain columns that contain dates, where it replaces the date with a...
3
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.