Not recognizing specification

  • Thread starter Thread starter Maracay
  • Start date Start date
M

Maracay

Hi gurus,

I have the next code to export a .TAB file with a specification, but I am
getting an error: QryAgentPrintOutsFileTABExp not defined, look like is not
recognizing the specification I created before.

Thanks

Dim strFileName As String
Dim rsa As Recordset
Dim dbs As Database
Set dbs = CurrentDb
Set rsa = dbs.OpenRecordset("qryAgentPrintOutsFile", dbOpenDynaset)
strFileName = "D:\Orlando\edward\PruebaTest.TAB"

DoCmd.TransferText acExportDelim, QryAgentPrintOutsFileTABExp,
"qryAgentPrintOutsFile", strFileName, True
 
Try to export the query first with help of the wizard to see if that works.
That way you can first conclude if the query is correct (you don't have any
dots . in the headers do you?). If the wizard continues as expected then the
next step will be to evaluate your code again.
 
Maracay said:
Hi gurus,

I have the next code to export a .TAB file with a specification, but I am
getting an error: QryAgentPrintOutsFileTABExp not defined, look like is
not
recognizing the specification I created before.

Thanks

Dim strFileName As String
Dim rsa As Recordset
Dim dbs As Database
Set dbs = CurrentDb
Set rsa = dbs.OpenRecordset("qryAgentPrintOutsFile", dbOpenDynaset)
strFileName = "D:\Orlando\edward\PruebaTest.TAB"

DoCmd.TransferText acExportDelim, QryAgentPrintOutsFileTABExp,
"qryAgentPrintOutsFile", strFileName, True


You need to provide the name of the specification as a quoted string:

DoCmd.TransferText acExportDelim, _
"QryAgentPrintOutsFileTABExp", _
"qryAgentPrintOutsFile", _
strFileName, _
True

Here's a question for you: why are you opening a recordset on the query you
are exporting? Do you think you need to do that in order to export it? You
don't. As far as I can tell (though I admit I don't know everything about
what you're trying to do), you don't need these lines at all:
 
Hi Dirk,

You were wright in everything, the only thing is that the file is created
with the header (Column's name) in the first row, even when in the
specification doesn't have this option, any idea what the problem is?

Thanks
 
Maracay said:
Hi Dirk,

You were wright in everything, the only thing is that the file is created
with the header (Column's name) in the first row, even when in the
specification doesn't have this option, any idea what the problem is?

Your last argument to TransferText is explicitly requesting it. Change
this:

.... to this:

DoCmd.TransferText acExportDelim, _
"QryAgentPrintOutsFileTABExp", _
"qryAgentPrintOutsFile", _
strFileName, _
False
 
Back
Top