473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting MS Access table to text file and appending current date to file name.

5 New Member
I have a table that I need to export out to a text fiel, without column headers. I also need to have the file name include currernt date. Can anyone help me? I'm using the following code:


[b]Public Function CreateFiles()

Dim db As Database
Dim rst As Recordset
Dim m_str As String
Dim dt_str As String
Dim y_str As String
Dim d As Variant
Dim dir_str As String
Dim loc As String, fl As String, I As Integer





d = FreeFile

m_str = Format(InputBox("Specify Month", , Month(Date)), "00")
If m_str = "" Then
Exit Function
End If

dt_str = Format(InputBox("Specify Day", , Day(Date)), "00")
If dt_str = "" Then
Exit Function
End If


y_str = InputBox("Specify Year", , Year(Date))
If y_str = "" Then
Exit Function
End If
Set db = CurrentDb



For I = Len(db.Name) To 1 Step -1
If Mid(db.Name, I, 1) = "\" Then
Exit For
End If
Next I
loc = Left(db.Name, I) & "Batches\Pmts_by_Checks_"



Set rst = db.OpenRecordset("PMTS_BY_Checks", dbOpenSnapshot)

Open loc & "PMTS_BY_Checks_" & m_str & dt_str & Right(y_str, 2) & ".txt" For Output As d
Do

Print #d, [AccountNumber] & "," & !Amount & "," & !PMTType & "," & ![PaymentDate] & "," & ![Description] & "," & "," & ![InvoiceNum] & "," & ![Check #]
.MoveNext
Loop While Not .EOF

Close d


End Function


I get the following error message:

Comile Error

External name not defined

It looks like error near Print #D, [AccountNumber]


Thank you in advance.
Apr 11 '07 #1
2 3339
pks00
280 Recognized Expert Contributor
How about something simple like this

DoCmd.TransferText acExportDelim, , "PMTS_BY_Checks", "c:\tsdn\Pmts_by_Checks_" & Format(Now(), "yyyymmdd") & ".txt", False

this exports to a folder called c:\tsdn
datetimestamp is YYYYMMDD

eg

filename is Pmts_by_checks_20070411
Apr 11 '07 #2
mamin
5 New Member
Thank you. It worked but the only thing I do not want is quotes around each text field.

How about something simple like this

DoCmd.TransferText acExportDelim, , "PMTS_BY_Checks", "c:\tsdn\Pmts_by_Checks_" & Format(Now(), "yyyymmdd") & ".txt", False

this exports to a folder called c:\tsdn
datetimestamp is YYYYMMDD

eg

filename is Pmts_by_checks_20070411
Apr 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
5
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because...
3
by: premmehrotra | last post by:
I am using Access 2000 and Oracle 9.2.0.x on a Windows 2000. I have setup Oracle 9.2 ODBC Driver (I have not yet figured how to set Microsoft's Oracle ODBC driver). I am exporting a table from...
1
by: Korvath | last post by:
I am trying to export an Access table with ~118,000 records to Paradox 4.5. I am receiving an error message Reserved Error (-5016). This error has no description, so I am at a loss to fix this...
10
by: HenHouse | last post by:
Hi folks; Hey wow! First post! Hope it bears fruit... Anyway, I've been teaching myself Access since March by writing an event/contact management database for the firm I work for. It's...
2
by: aloke.sarnobat | last post by:
Hello, I am new to this forum, so your help would be most appreciated. I am trying to create a javascript where, on clicking a button, I will be able to download the latest log file. But the...
1
by: JFKJr | last post by:
Hi! I have exported an access table data into an excel file using the following code. However, the code exported all the data to the excel sheet starting from 'A' cell (first column). But I want to...
3
by: sarah2855 | last post by:
Hello All, I'm looking for the vb code that export an access table to specific worksheet in Excel. I tried to search see if this question was answered before here, but didn't find anything that...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.