Object Name does not follow Microsoft Access object-naming rules

  • Thread starter Thread starter clk
  • Start date Start date
C

clk

I have a database built to export the contents of a text file to the c:
\ drive. I need to have this .txt file saved with a particular name.
It must contain MineNumber!!AOIEDD_CompanyTechDate.txt

I get an error message on creation of the file name with the error of
"Object Name does not follow Microsoft Access object-naming rules".

Any help is greatly appreciated.

Here is my code:


Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset

Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryGetTextFileData", dbOpenSnapshot)


DoCmd.OpenQuery "qryCreateTableforTextFile"


DoCmd.TransferText transfertype:=acExportDelim, _
specificationname:="tblTextFileSpecs", _
tablename:="tblTextFile", _
FileName:="C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_" &
Forms!frmCreateTextFile!Company & rsEmail![Last Name] _
& Format(rsEmail!dateoffile, "MDYYYY") & ".txt", _
hasfieldnames:=True

DoCmd.OpenQuery "qryDeleteTextFileData"
 
I would construct the file name into a variable, so I could look at it and see
if I could determine why the error was being generated.
Dim strFileName
strFileName = "C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_" &
Forms!frmCreateTextFile!Company & rsEmail![Last Name] _ &
Format(rsEmail!dateoffile, "MDYYYY") & ".txt"

Perhaps there is something in the Company or Last Name that is causing the error?

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
I would construct the file name into a variable, so I could look at it and see
if I could determine why the error was being generated.
Dim strFileName
strFileName = "C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_" &
  Forms!frmCreateTextFile!Company & rsEmail![Last Name] _ &
Format(rsEmail!dateoffile, "MDYYYY") & ".txt"

Perhaps there is something in the Company or Last Name that is causing the error?

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County


I have a database built to export the contents of a text file to the c:
\ drive.  I need to have this .txt file saved with a particular name.
It must contain MineNumber!!AOIEDD_CompanyTechDate.txt
I get an error message on creation of the file name with the error of
"Object Name does not follow Microsoft Access object-naming rules".
Any help is greatly appreciated.
Here is my code:
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryGetTextFileData", dbOpenSnapshot)
DoCmd.OpenQuery "qryCreateTableforTextFile"
DoCmd.TransferText transfertype:=acExportDelim, _
   specificationname:="tblTextFileSpecs", _
   tablename:="tblTextFile", _
   FileName:="C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_" &
Forms!frmCreateTextFile!Company & rsEmail![Last Name] _
   & Format(rsEmail!dateoffile, "MDYYYY") & ".txt", _
   hasfieldnames:=True
DoCmd.OpenQuery "qryDeleteTextFileData"- Hide quoted text -

- Show quoted text -

The problem is that if I try to include the !! in the file name, it
changes the .txt to #txt. If I leave off the two exclamation points
the code works great. Any way to include a symbol in a file name?
 
I would construct the file name into a variable, so I could look at it and see
if I could determine why the error was being generated.
Dim strFileName
strFileName = "C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_"&
  Forms!frmCreateTextFile!Company & rsEmail![Last Name] _ &
Format(rsEmail!dateoffile, "MDYYYY") & ".txt"
Perhaps there is something in the Company or Last Name that is causing the error?
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
clk said:
I have a database built to export the contents of a text file to the c:
\ drive.  I need to have this .txt file saved with a particular name.
It must contain MineNumber!!AOIEDD_CompanyTechDate.txt
I get an error message on creation of the file name with the error of
"Object Name does not follow Microsoft Access object-naming rules".
Any help is greatly appreciated.
Here is my code:
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryGetTextFileData", dbOpenSnapshot)
DoCmd.OpenQuery "qryCreateTableforTextFile"
DoCmd.TransferText transfertype:=acExportDelim, _
   specificationname:="tblTextFileSpecs", _
   tablename:="tblTextFile", _
   FileName:="C:\PalmsImport\" & rsEmail!ERIMSMine & "([!!])AOIEDD_" &
Forms!frmCreateTextFile!Company & rsEmail![Last Name] _
   & Format(rsEmail!dateoffile, "MDYYYY") & ".txt", _
   hasfieldnames:=True
DoCmd.OpenQuery "qryDeleteTextFileData"- Hide quoted text -
- Show quoted text -

The problem is that if I try to include the !! in the file name, it
changes the .txt to #txt.  If I leave off the two exclamation points
the code works great.  Any way to include a symbol in a file name?- Hide quoted text -

- Show quoted text -

I figured this out and wanted to post the code in case any one else
had the issue. I found this on a group and tried it. Sorry couldn't
find the original to give credit to the person who posted similar code
on another site.

Dim FileName As String
Dim NewFileName As String
FileName = "C:\palmsimport\MyFile.txt"
NewFileName = "C:\PalmsImport\" & rsEmail!ERIMSMine & "!!AOIEDD_" &
Forms!frmCreateTextFile!Company & rsEmail!LName _
& Format(rsEmail!dateoffile, "MDYYYY") & ".txt"
Name FileName As NewFileName

I named the file something generic to export it and then renamed the
file to what I needed it to be. Worked perfectly!

Thanks for the input on this issue.
 
Back
Top