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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting from access database 1

Status
Not open for further replies.
Jun 1, 2006
58
US
Hi all,

I have some tables in an access database that I need to export into text files. When I export these tables, I also need the name of the database(not the table)to somehow be included, either as a seperate column or as a suffix to one of the columns or simply as a header etc...

right now, after exporting the data I am manually including the name of the database. I am wondering if there is a better way of capturing the name of the database and exporting that along with the table.

Any help is appreciated.

Thanks
 
Hi,

Do a query with the DB name in a column. Export the query results.

Skip,

[glasses] [red][/red]
[tongue]
 
Hi,
so you are suggesting that I run a select query, include the db name as one of the display objects, and export the results?

Will try,
Thanks.
 
I have one more question.

These databases will change monthly. Every month a new database will be created with a new name. Is there a command wherein I can automatically get the name of the database or would I have to input the name myself in the select query?

Thanks
 
You could write a function like:
Code:
Public Function CurrDB() As String
On Error Resume Next
Dim dbs As Database
Set dbs = CurrentDb
CurrDB = dbs.name
End Function
Then call it from your query:
Code:
SELECT tblname.*, CurrDB() AS DBPath
FROM tblname;
which would return ...C:\DATA\test.mdb or whatever.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top