Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting as a .dbf file

Status
Not open for further replies.

famousb

Programmer
Mar 2, 2000
239
US
I need to export a table/query as a .dbf file. i've managed to do it as a .txt or .xls, but haven't seemed to be able to do the same thing with the .dbf format. <br>
can anyone provide me with the actual VB or code otherwise?<br>
<br>
thanks in advance. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Well lets start by seeing your code. <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
ok, here is a sample code of the procedure that i am trying to accomplish. I want to export to dbase IV eventually. I know i can do this through a Macro really easy, but that takes the fun out of it. Is there a way that i can create the database (or just the table) to be exported to on the fly so it doesn't have to pre-exist?<br>
<br>
Private Sub Command47_Click()<br>
Dim DB As String<br>
Dim stDocName As String<br>
Dim DBtype As String<br>
Dim TB As String<br>
<br>
DB = &quot;test.mdb&quot;<br>
stDocName = &quot;qbf2ActiveFull&quot;<br>
DBtype = &quot;Microsoft Access&quot;<br>
TB = &quot;Table&quot;<br>
<br>
DoCmd.TransferDatabase acExport, DBtype, DB, acTable, stDocName, TB, 0<br>
End Sub<br>
<br>
Thanks, for helping out. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
You appear to have the whole thing backwards.<br>
<br>
DoCmd.TransferDatabase [transfertype], databasetype, databasename[, objecttype], source, destination[, structureonly][, saveloginid]<br>
<br>
OK if you are wanting to export to Dbase then this variable &quot;DBtype&quot; should be &quot;dBASE&quot; not &quot;Microsoft Access&quot;<br>
&quot;DB&quot; should be the name of your exported dBase file not your Access database <br>
&quot;acTable&quot; is the type of object in your Access database such as a table or query.<br>
Double click on the word &quot;TransferDatabase&quot; in your code window and Press F1 this will bring up help study the examples and what each paramter is.<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
sorry for not clarifying this before, but test.mdb is a new Access database that i created to export to - that is why i have DBtype defined as &quot;Microsoft Access&quot;. I have already printed out the help file for &quot;TransferDatabase&quot;. I think my real question has evolved to &quot;Is it possible to export to a database that doesn't previously exist?&quot;<br>
<br>
I'm thinking that i would have to combine the previous code with code that creates a new dBase database, but i'm not sure if this is possible. This is the point where i am getting stuck.<br>
<br>
Sorry, and thanks. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
I'm not sure.<br>
I have not needed to work with a .MDB that did not exist.<br>
Keep this in mind &quot;Sometime's there is only so much you can automate&quot;.<br>
<br>
If it is possible, it require a lot of work.<br>
<br>
I don't think it can be done with the <br>
docmd.transfer...<br>
Look at Creating recordsets from scratch<br>
<br>
CREATE TABLE table (field1 type [(size)] [NOT NULL] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Just thought of something else.<br>
<br>
First you have to create a .MDB before you can do something with it.<br>
you can not just export a DBF to something that does not exist yet or expect it to create a .MDB on the fly within the docomd.<br>
So in your code create a new .MDB using the Create Table then below that try the docmd.transfer Export thing. <br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
I use the following to export access data to a dBase III file.<br>
<br>
"c:\AccessDBF" is path to whee you want the DBF created.<br>
This must be a valid path.<br>
"Mtr_res" is name of the Access Table to export.<br>
"Test1.dbf" is name of DBF to create.<br>
<br>
DoCmd.TransferDatabase A_EXPORT, "dBASE III",<br>
"c:\AccessDBF", A_TABLE, "Mtr_res", "Test1.dbf"
 
thanks, i think all of the advice will prove useful. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top