Solved

RUN TIME ERRO 52

Posted on 2010-09-17
6
515 Views
Last Modified: 2012-05-10


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

0
Comment
Question by:crystalsoft
6 Comments
 
LVL 13

Expert Comment

by:AielloJ
ID: 33700510
crystalsoft:

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

AielloJ
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33700554
Make sure that csvflname = text1(8) & ".csv" contains a valid name and not something like this ".csv"
Check the value of text1(8)
0
 
LVL 1

Author Comment

by:crystalsoft
ID: 33700566

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 125 total points
ID: 33700598
does 43.csv exist?

try text1(8).text

see this link:
http://www.experts-exchange.com/Programming/Misc/Q_26474347.html
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 33700601
What is the value of #iFileNo ?

Perhaps you need to add something like this:

#iFileNo = freefile()
Open csvflname for output as #iFileNo
0
 
LVL 14

Expert Comment

by:VBClassicGuy
ID: 33702367
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What language/protocol is the Angular Chat? 2 73
Tax Considerations for positive outcomes, outside the U.S. for IT Professionals 3 42
MsgBox 4 59
Message not shown 5 49
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question