![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. *At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, *Anyone able to advise?. |
#3
| |||
| |||
|
|
I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, Anyone able to advise?. |
#4
| |||
| |||
|
|
Unfortunately I am unable to link to the files. There is a separate file for each day. I can copy each file from the server to a folder on my computer. I then need to import each file to access. I need to do this for every day of 2009. I have a an import macro (copied from a newsgroup years ago) to import all text file in a folder, then run and append query to append the master table and I was hoping to find something similar for DBF files. |
|
"Chuck Grimsby" <cgatgoo (AT) gmail (DOT) com> wrote in message news:001a8d1e-24f5-4a6e-ae9a-6883088acbb4 (AT) s9g2000yqd (DOT) googlegroups.com... On Aug 12, 3:14 pm, "Aileen Turner" <taxiail... (AT) yahoo (DOT) com.au> wrote: I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, Anyone able to advise?. Why not just link to the DBF files and run a import query against the file? Drop the link when you're done, then move on to the next. You can also do this for the text and excel files.... |
#5
| |||
| |||
|
|
Taxi Aileen wrote: Unfortunately I am unable to link to the files. *There is a separate file for each day. *I can copy each file from the server to a folder on my computer. I then need to import each file to access. *I need to do this for every day of 2009. I have a an import macro (copied from a newsgroup years ago) to import all text file in a folder, then run and append query to append the master table and I was hoping to find something similar for DBF files. Here's a sample sub to scan all files in the folder. Sub ScanDBFFilesInFolder(strFolder As String) * * *Dim s As String * * *If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\" * * *'find first dbf file * * *s = Dir(strFolder & "*.dbf") * * *Do While s > "" * * * * *Debug.Print s * * * * *'find next dbf file * * * * *s = Dir() * * *Loop * * *MsgBox "Done. *All dbfs viewed" End Sub If you can import them, you can link to them. *I assume your are doing it by hand. *That has to be a drag. * * * * Docmd.TransferDatabase acLink, "dBase III",... Here's an example from Help DoCmd.TransferDatabase acImport, "Microsoft Access", _ * * *"C:\My Documents\NWSales.mdb", acReport, "NW Sales for April",_ * * *"Corporate Sales for April" You might have to futz with it, try different types, but if you are doing it manually you'll know which database type to use. You'd then run that acLink, then the query to append, prior to the s=Dir() line. *I'd recommend you have make a copy before running and doing testing of the mdb that has the backend tables. "Chuck Grimsby" <cgat... (AT) gmail (DOT) com> wrote in message news:001a8d1e-24f5-4a6e-ae9a-6883088acbb4 (AT) s9g2000yqd (DOT) googlegroups.com... On Aug 12, 3:14 pm, "Aileen Turner" <taxiail... (AT) yahoo (DOT) com.au> wrote: I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, Anyone able to advise?. Why not just link to the DBF files and run a import query against the file? *Drop the link when you're done, then move on to the next. You can also do this for the text and excel files.... |
#6
| |||
| |||
|
|
Taxi Aileen wrote: Unfortunately I am unable to link to the files. There is a separate file for each day. I can copy each file from the server to a folder on my computer. I then need to import each file to access. I need to do this for every day of 2009. I have a an import macro (copied from a newsgroup years ago) to import all text file in a folder, then run and append query to append the master table and I was hoping to find something similar for DBF files. Here's a sample sub to scan all files in the folder. Sub ScanDBFFilesInFolder(strFolder As String) Dim s As String If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\" 'find first dbf file s = Dir(strFolder & "*.dbf") Do While s > "" Debug.Print s 'find next dbf file s = Dir() Loop MsgBox "Done. All dbfs viewed" End Sub If you can import them, you can link to them. I assume your are doing it by hand. That has to be a drag. Docmd.TransferDatabase acLink, "dBase III",... Here's an example from Help DoCmd.TransferDatabase acImport, "Microsoft Access", _ "C:\My Documents\NWSales.mdb", acReport, "NW Sales for April", _ "Corporate Sales for April" You might have to futz with it, try different types, but if you are doing it manually you'll know which database type to use. You'd then run that acLink, then the query to append, prior to the s=Dir() line. I'd recommend you have make a copy before running and doing testing of the mdb that has the backend tables. "Chuck Grimsby" <cgat... (AT) gmail (DOT) com> wrote in message news:001a8d1e-24f5-4a6e-ae9a-6883088acbb4 (AT) s9g2000yqd (DOT) googlegroups.com... On Aug 12, 3:14 pm, "Aileen Turner" <taxiail... (AT) yahoo (DOT) com.au> wrote: I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, Anyone able to advise?. Why not just link to the DBF files and run a import query against the file? Drop the link when you're done, then move on to the next. You can also do this for the text and excel files.... |
#7
| |||
| |||
|
|
On Aug 14, 10:08 pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: Taxi Aileen wrote: Unfortunately I am unable to link to the files. There is a separate file for each day. I can copy each file from the server to a folder on my computer. I then need to import each file to access. I need to do this for every day of 2009. I have a an import macro (copied from a newsgroup years ago) to import all text file in a folder, then run and append query to append the master table and I was hoping to find something similar for DBF files. Here's a sample sub to scan all files in the folder. Sub ScanDBFFilesInFolder(strFolder As String) Dim s As String If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\" 'find first dbf file s = Dir(strFolder & "*.dbf") Do While s > "" Debug.Print s 'find next dbf file s = Dir() Loop MsgBox "Done. All dbfs viewed" End Sub If you can import them, you can link to them. I assume your are doing it by hand. That has to be a drag. Docmd.TransferDatabase acLink, "dBase III",... Here's an example from Help DoCmd.TransferDatabase acImport, "Microsoft Access", _ "C:\My Documents\NWSales.mdb", acReport, "NW Sales for April", _ "Corporate Sales for April" You might have to futz with it, try different types, but if you are doing it manually you'll know which database type to use. You'd then run that acLink, then the query to append, prior to the s=Dir() line. I'd recommend you have make a copy before running and doing testing of the mdb that has the backend tables. "Chuck Grimsby" <cgat... (AT) gmail (DOT) com> wrote in message news:001a8d1e-24f5-4a6e-ae9a-6883088acbb4 (AT) s9g2000yqd (DOT) googlegroups.com... On Aug 12, 3:14 pm, "Aileen Turner" <taxiail... (AT) yahoo (DOT) com.au> wrote: I have hundreds of dbf files to import from a folder to a table in access 2003 and or 2007. At present I import each file as a table then copy and paste to a master table. For other imports (text, excel etc) I have a macro to import all files in a folder, but I have no option to import DBF files, Anyone able to advise?. Why not just link to the DBF files and run a import query against the file? Drop the link when you're done, then move on to the next. You can also do this for the text and excel files.... Good code Salad! Since you can just link to the DBFs, rather then doing a Transfer, I'd suggest just doing that, linking rather then importing. Often what I see is that programmers import everything then run a series of queries against the imported data to get whatever they need in the format they need it in. A lot of work for little return. Instead, if they just link to the data, often a query or two can do all of that in one procedure. So rather then TransferDatabase, it's often better to link to the data as if it were a seperate table (since it already is) via the CreateTableDef command, and just do whatever query(s) are needed. Faster and less repeated work for each link each time the data is imported. This works for Excel and CSV or TSV files as well as DBFs. Just remember you can't do update queries on these files! |
#8
| |||
| |||
|
|
s = Dir(strFolder & "*.dbf") |
![]() |
| Thread Tools | |
| Display Modes | |
| |