Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

assigning current date to a variable & exporting a tbl to a CSV fi

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pepenacho - 31 Mar 2005 18:13 GMT
Good morning:

I have a two part question. I need to manipulate a table name a bit and then
export it into a CSV file on my hardrive. I have most of the pseudo-code
figured out; these are the only (below) pieces that will be tricky for me. My
handy Wrox book does not seem to have this anywhere, but by infrence from my
intro to VB.Net class, this should be possible - so this is a product of my
imagination. Thanks in advance. Pepenacho

Let's say I have a tblA

This is the p-code:

Private Sub ()
Dim variable1 As String

variable1=current date

'this is the part I don't know, how do I assign the value of today's date to
the variable; I need the format of the date to be i.e. 03312005

DoCmd.Rename tblA as variable1

DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\mytbls", acTable,
variable1, 03312005.csv

'this is the second part I do not know how to pull off; I need some sort of
a DoCmd.XXXX method or something to export a copy of the tbl to a CSV file on
the hard drive; I know the above is incorrect

End Sub
'69 Camaro - 31 Mar 2005 19:41 GMT
Hi.

> I have a two part question. I need to manipulate a table name a bit and then
> export it into a CSV file on my hardrive.

Try the following code to rename the existing table, then export it to a CSV
file (including field names as headers):

' * * * * Start Code * * * *

Private Sub ExportTblBtn_Click()

   On Error GoTo ErrHandler
   
   Dim sToday As String
   
   sToday = Format(Date, "mmddyyyy")
   DoCmd.Rename sToday, acTable, "tblA"
   DoCmd.TransferText acExportDelim, , sToday, "C:\mytbls\" & sToday &
".csv", True

   Exit Sub
   
ErrHandler:
   
   MsgBox "Error in ExportTblBtn_Click( ) in" & vbCrLf & Me.Name & _
               " form." & vbCrLf & vbCrLf & _
               "Error #" & Err.Number & vbCrLf & Err.Description
   Err.Clear

End Sub

' * * * * End Code * * * *

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions.  Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.

> Good morning:
>
[quoted text clipped - 27 lines]
>
> End Sub
pepenacho - 31 Mar 2005 20:21 GMT
Looks nice, I'll give it a whirl.

Thank you.

Pepe

> Hi.
>
[quoted text clipped - 79 lines]
> >
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.