Export specification (1 Viewer)

ypma

Registered User.
Local time
Today, 12:30
Joined
Apr 13, 2012
Messages
643
Hello, my problem is that I am trying to export a query to a text file. I followed the procedure which worked when clicking the Run button and created a specification. When viewing the saved exports the specification is there. But when if try run the code in VBA I receive "The text file specification ' does not exist. You cannot import, export, or link using the specification." I have other specifications which work fine, these were imported when I upgraded from 2003.Note these don't show in the list of save exports.

It seem as if the specification is not being saved and assistance would be appreciated
ADDED CODE
#Private Sub Command507_Click()
On Error GoTo ProcError
Dim strPath As String
strPath = CurrentProject.Path
DoCmd.TransferText TransferType:=acExportDelim, _
SpecificationName:="ContactHome Source Specification", _
TableName:="qryPhoneSource6-1", _
FileName:=strPath & "\ContactHome.txt", _
HasFieldNames:=0
MsgBox "The selected Home Phone numbers have been exported " _
& "to the file ContactHome.txt" & vbCrLf _
& "in the folder:" & vbCrLf & strPath, vbInformation, _
"Export Complete..."
ExitProc:
Exit Sub

ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in cmdExportTabDelim_Click event procedure..."
Resume ExitProc
End Sub#
Ypma
 
Last edited:

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:30
Joined
Apr 27, 2015
Messages
6,317
Posting your code would help the troubleshooting process...
 

ypma

Registered User.
Local time
Today, 12:30
Joined
Apr 13, 2012
Messages
643
NauticalGent. Point taken , I have now added my code. Note this code works ok on old specification but not new one

Regards Ypma
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:30
Joined
Apr 27, 2015
Messages
6,317
Ypma, no worries. Didn't mean to come off as snarky; I failed finishing school.

At first glance, I would suggest removing the SpecificationName bit. It's optional and Access is obviously looking for something that no longer exists.
 

ypma

Registered User.
Local time
Today, 12:30
Joined
Apr 13, 2012
Messages
643
Yesterday 01:52 PM
NauticalGent: Thank you for you suggestion, which I will try later , as my 77 year old body is playing up. I was wondering if my access problem is a common fault with access 2010 ? Will let you know how I get on in due course .

Regards Ypma
 

ypma

Registered User.
Local time
Today, 12:30
Joined
Apr 13, 2012
Messages
643
NauticalGent: You got it in one. By removing the spec the code ran as it should do , thank you.

Regards Ypma
 

gerrywiles

New member
Local time
Today, 12:30
Joined
May 14, 2011
Messages
3
I am running vba from a command button to export a query to a csv file. Everything works well but each field in enclosed with quotation " marks. I have read that I need to set or change an export spec (schema.ini) but cannot see how to do this. I can see that by using a wizard I can do this on advanced setting on an import routine but I cannot seem to do this for an export routine. I am coding as follows
docmd.transfertext acexportDelim, ,"qryname","C:\test.csv"
Can somebody explain how I can create/edit a scheme to include in the above line
Thank you Gerry
 

ypma

Registered User.
Local time
Today, 12:30
Joined
Apr 13, 2012
Messages
643
gerrywiles :May be the blind leading the blind , but I start the export of the query by highlighting the subject query and right click and click export to excel. This then takes you to export form which allows you the option to specify export options .you then click the Ok and follow to the end and finally save export steps Your cmd. button should now work . If you have already carried out this procedure other members of this forum my be able to advise.

Regards Ypma
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:30
Joined
Feb 19, 2002
Messages
43,196
The only way to bring up the import/export dialog is to actually start the process. Once the dialog opens, you will see an Advanced button. Pressing the Advanced button will allow you to select a saved spec which you can modify. Save the spec before exiting.

Specs can be copied from other databases. Open the get external data wizard and choose Access. Specs will be a special option and you can import just the spec without importing any other items.
 

gerrywiles

New member
Local time
Today, 12:30
Joined
May 14, 2011
Messages
3
thank you all for the responses - everything is now clear and I have overcome the issue.
Just to advise that I had tried to create an export by right clicking the table or query etc and exporting as a Text file. The error I was making was that I was checking the Output with Formatting box and this did not allow me the options for delimiters, quote marks etc...

Again many thanks
Gerry
 

Users who are viewing this thread

Top Bottom