RUN TIME ERRO 52



Run-time error '52'

Bad file name or number

On debug highlighted on following line
Open csvflname for output as #iFileNo


Dim iFileNo as integer
dim csvflname as integer

csvflname = text1(8) & ".csv"

Open csvflname for output as #iFileNo

Open in new window

LVL 1
crystalsoftAsked:
Who is Participating?
 
DhaestCommented:
What is the value of #iFileNo ?

Perhaps you need to add something like this:

#iFileNo = freefile()
Open csvflname for output as #iFileNo
0
 
AielloJCommented:
crystalsoft:

Where is the varible 'text1' initialized?  Try printing csvfilename and text1 for debug purposes.

AielloJ
0
 
DhaestCommented:
Make sure that csvflname = text1(8) & ".csv" contains a valid name and not something like this ".csv"
Check the value of text1(8)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
crystalsoftAuthor Commented:

Thanks for quick reply sir

text1(8) is a text box

csvflname = text1(8) & ".csv"

on debug i am getting file name like 43.csv

43 is value from text1(8)
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
does 43.csv exist?

try text1(8).text

see this link:
http://www.experts-exchange.com/Programming/Misc/Q_26474347.html
0
 
VBClassicGuyCommented:
Just an observation no one picked up on, and something to watch out for in the future. In your original posted code, you declared csvflname as an integer, then assigned a text value to it. That's a no-no.
Fixing that and setting iFileNo with FreeFile would have made the code work (assuming text1(8) is a valid control on your form).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.