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

P

pepenacho

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
 
6

'69 Camaro

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.
 
Top