Error Number 52: Bad file name or number

G

Guest

Trying to import an "Export" file from Syware Visual CE. It creates an ASCII
file, but doesn't have an extension. A sample file is 050014083106...and
calls itself a "text" file. I then save that file as an Excel CSV file.

The code snippet below fails on the Open statement. It is attempting to Open
"C:\CEFiles\050014083106.csv" in this case.

Any ideas??? TIA - Bob

Open "C:\CEFiles\" & cboFileCE For Input As iNumOne <----Errors here as
Set Z = CurrentDb Error Number 52: Bad file name or number
Set RS = Z.OpenRecordset("FromCE")
Do Until EOF(iNumOne)
Input #iNumOne, vStore, vVarZ, vLastInsp, vOneVar, VQues, vTheQues, vAns, _
vComment, vSC, vCD, vCact, vOReason
With RS
.AddNew
!Store = Trim(vStore): !VarZ = vVarZ: !LastInsp = vLastInsp: !OneVar =
vOneVar
!Question = VQues: !Answer = vAns: !Comment = Trim(vComment): !SchCorr = vSC
!CorrDate = vCD: !CAction = Trim(vCact): !OReason = Trim(vOReason)
.Update
End With
Loop
 
G

Graham Mandeno

Hi Bob

What is the value of iNumOne at the time the error occurs? If you haven't
initialised it, then (assuming it's declared As Integer) it will be zero,
which would explain the error.

Insert:
iNumOne = FreeFile
before the Open statement.

Also, you should be able to open the original text file with no extension,
without opening it and saving in Excel.
 
D

Dirk Goldgar

Bob Barnes said:
Trying to import an "Export" file from Syware Visual CE. It creates
an ASCII file, but doesn't have an extension. A sample file is
050014083106...and calls itself a "text" file. I then save that file
as an Excel CSV file.

The code snippet below fails on the Open statement. It is attempting
to Open "C:\CEFiles\050014083106.csv" in this case.

Any ideas??? TIA - Bob

Open "C:\CEFiles\" & cboFileCE For Input As iNumOne <----Errors here

So what's actually in the bound column of the combo box? Does it end in
".csv" or not? does the combo box actually match the name of the file
you want to open?
 
R

Ron Hinds

Just before the line that is causing the error add the following line:

iNumOne = FreeFile

This will ensure that iNumOne is a valid file number.
 
G

Guest

That's it. I pasted the code and left out iNumOne = FreeFile

Thank you - Bob

Graham Mandeno said:
Hi Bob

What is the value of iNumOne at the time the error occurs? If you haven't
initialised it, then (assuming it's declared As Integer) it will be zero,
which would explain the error.

Insert:
iNumOne = FreeFile
before the Open statement.

Also, you should be able to open the original text file with no extension,
without opening it and saving in Excel.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob Barnes said:
Trying to import an "Export" file from Syware Visual CE. It creates an
ASCII
file, but doesn't have an extension. A sample file is 050014083106...and
calls itself a "text" file. I then save that file as an Excel CSV file.

The code snippet below fails on the Open statement. It is attempting to
Open
"C:\CEFiles\050014083106.csv" in this case.

Any ideas??? TIA - Bob

Open "C:\CEFiles\" & cboFileCE For Input As iNumOne <----Errors here as
Set Z = CurrentDb Error Number 52: Bad file name or
number
Set RS = Z.OpenRecordset("FromCE")
Do Until EOF(iNumOne)
Input #iNumOne, vStore, vVarZ, vLastInsp, vOneVar, VQues, vTheQues, vAns,
_
vComment, vSC, vCD, vCact, vOReason
With RS
.AddNew
!Store = Trim(vStore): !VarZ = vVarZ: !LastInsp = vLastInsp: !OneVar =
vOneVar
!Question = VQues: !Answer = vAns: !Comment = Trim(vComment): !SchCorr =
vSC
!CorrDate = vCD: !CAction = Trim(vCact): !OReason = Trim(vOReason)
.Update
End With
Loop
 
G

Guest

That's it - I pasted the code and didn't left out iNumOne = FreeFile.

Thank you - Bob

:

Hi Bob

What is the value of iNumOne at the time the error occurs? If you haven't
initialised it, then (assuming it's declared As Integer) it will be zero,
which would explain the error.

Insert:
iNumOne = FreeFile
before the Open statement.

Also, you should be able to open the original text file with no extension,
without opening it and saving in Excel.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Bob Barnes said:
Trying to import an "Export" file from Syware Visual CE. It creates an
ASCII
file, but doesn't have an extension. A sample file is 050014083106...and
calls itself a "text" file. I then save that file as an Excel CSV file.

The code snippet below fails on the Open statement. It is attempting to
Open
"C:\CEFiles\050014083106.csv" in this case.

Any ideas??? TIA - Bob

Open "C:\CEFiles\" & cboFileCE For Input As iNumOne <----Errors here as
Set Z = CurrentDb Error Number 52: Bad file name or
number
Set RS = Z.OpenRecordset("FromCE")
Do Until EOF(iNumOne)
Input #iNumOne, vStore, vVarZ, vLastInsp, vOneVar, VQues, vTheQues, vAns,
_
vComment, vSC, vCD, vCact, vOReason
With RS
.AddNew
!Store = Trim(vStore): !VarZ = vVarZ: !LastInsp = vLastInsp: !OneVar =
vOneVar
!Question = VQues: !Answer = vAns: !Comment = Trim(vComment): !SchCorr =
vSC
!CorrDate = vCD: !CAction = Trim(vCact): !OReason = Trim(vOReason)
.Update
End With
Loop
 
G

Guest

That's it - I pasted the code and didn't left out iNumOne = FreeFile.

Thank you - Bob
 
G

Guest

Dirk,

The combo box has an SQL feeding it, & the Files end in .csv.

I had pasted the code and left out iNumOne = FreeFile.
That was it.

Thank you - Bob
 
D

Dirk Goldgar

Bob Barnes said:
Dirk,

The combo box has an SQL feeding it, & the Files end in .csv.

I had pasted the code and left out iNumOne = FreeFile.
That was it.

I didn't guess that -- kudos to Graham and Ron Hinds.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ASCII Again... 7

Top