473,379 Members | 1,170 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,379 software developers and data experts.

Import newly created .dbf files to MS ACCESS

31
I am trying to import .dbf files to ACCESS. The files all start with "QB" and then Numbers ie.. QB0001, QB0002. I am getting the files in but the code I have changes the name to the first file in the dir and increments all others from that file name. I am new to the coding game and need help on this one.

Expand|Select|Wrap|Line Numbers
  1. Private Sub_Import() 
  2.   Dim strPath As String 
  3.   Dim strTableName As String 
  4.   Dim strFileName As String 
  5.   Dim dbs As Database 
  6.  
  7.   Set dbs = CurrentDb 
  8.   strPath = "C:\NEWFOLDER\" 
  9.    strTableName = Dir(strPath) . 
  10.    strFileName = Dir(strPath & QB*.dbf") ' Retrieve the first entry file name. 
  11.      Do While strFileName <> "" ' Start the loop. 
  12.      DoCmd.TransferDatabase acImport, "dBase IV", strPath,, strFileName, 
  13. strTableName, False 
  14.    strFileName = Dir  
  15.    Loop 
  16. End Sub
Sep 20 '07 #1
1 2270
nico5038
3,080 Expert 2GB
I am trying to import .dbf files to ACCESS. The files all start with "QB" and then Numbers ie.. QB0001, QB0002. I am getting the files in but the code I have changes the name to the first file in the dir and increments all others from that file name. I am new to the coding game and need help on this one.

Expand|Select|Wrap|Line Numbers
  1. Private Sub_Import() 
  2.   Dim strPath As String 
  3.   Dim strTableName As String 
  4.   Dim strFileName As String 
  5.   Dim dbs As Database 
  6.  
  7.   Set dbs = CurrentDb 
  8.   strPath = "C:\NEWFOLDER\" 
  9.    strTableName = Dir(strPath) . 
  10.    strFileName = Dir(strPath & "QB*.dbf") ' Retrieve the first entry file name. 
  11.      Do While strFileName <> "" ' Start the loop. 
  12.      DoCmd.TransferDatabase acImport, "dBase IV", strPath,, strFileName, 
  13. strTableName, False 
  14.    strFileName = Dir  
  15.    Loop 
  16. End Sub
Not sure what your objective is. Besides a missing " before the QB*.dbf", all code look OK to me.
When you want each QB file to be stored into a different table, then use the strFilename (without .dbf) also for the tablename in the Docmd:
Expand|Select|Wrap|Line Numbers
  1.    strFileName = Dir(strPath & QB*.dbf") ' Retrieve the first entry file name. 
  2.      Do While strFileName <> "" ' Start the loop.  
  3.      DoCmd.TransferDatabase acImport, "dBase IV", strPath,, strFileName, 
  4. Replace(strFileName,".dbf",""), False 
  5.    strFileName = Dir  
  6.    Loop 
  7. End Sub
Nic;o)
Oct 5 '07 #2

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

Similar topics

0
by: Helena Cai | last post by:
Hi, Due to the nature of our system, we need to dynamically import certificate files into windows certificates store and access the certificate store from ASP pages, these ASP pages call a VB...
3
by: *no spam* | last post by:
I want to move my Access 2K database into MSDE. The Access Upsizing Wizard crashes (a known bug wi A2K), so I'm using the following suggested method: Access --> New --> Project (Existing...
1
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my...
3
by: deko | last post by:
I've been trying to use the Access Import Wizard to expedite importing data into my mdb. The nice thing about the wizard is that I can import from different file formats - txt, xls, even Outlook -...
1
by: David Berry | last post by:
Hi All. I'm looking for any help or sample code that can show me how to make a file import wizard in ASP.NET (VB preferred) like the one that MS Access uses. I'm working on a web site where the...
3
by: ninrulz | last post by:
I will try to explain my situation. I know that it is hard to offers solutions without fully understanding what people would like to achieve. I receive 2 csv files every month. The csv files...
1
by: Child of His | last post by:
I have been through every trick I know, or has been suggested. I have a one to two million line fixed field database in text format. I want to bring it into Access 97. When I use the external...
4
by: db2admin | last post by:
Hello, If i import data into tables, import will write all warnings in message file and will tell me why any exception row is rejected. I wanted to get exception rows in seperate table which i...
5
geolemon
by: geolemon | last post by:
Import text wizard says: I'm banging my head on this one, here's why: I've been importing files using this process and data format, with success! I created a temporary table in Access to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.