?
Solved

How do I check for a valid local address to save a file?

Posted on 2011-02-21
10
Medium Priority
?
300 Views
Last Modified: 2012-05-11
I have a form that has a field with a http address and a field with a folder location. The command button when clicked downloads the file to the local folder. If the folder location is null it ask to browse to a location to save it. If the folder location has an address it saves it there. The problem is what if the folder location is in valid? i have attached file.  FileCopySave.mdb
0
Comment
Question by:seanlhall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34943413
what is your basis for valid folder location?
0
 

Author Comment

by:seanlhall
ID: 34943614
For exaample if in the folder location it has a location that is not on that computer it will say it is save there even though it does not exsist. I would like the browse for folder to come up if the location is not correct.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34943648


if dir(me.txtFolderLocation,vbdirectory)="" then
   msgbox "Folder does not exists"
   exit sub
   else

    'save file here
end if
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 44

Expert Comment

by:GRayL
ID: 34943801
How can your BrowseFolder function find a location that is not valid?  
0
 

Author Comment

by:seanlhall
ID: 34943862
runtime error 52 bad file or number. This happens when folderlocation is null, has valid address or not.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34943879
seanlhall,
did you try the codes  i posted above?
0
 

Author Comment

by:seanlhall
ID: 34943880
The folder location is where it is saved. If the location entered in the folder location is not valid for some reason, it will said it has saved the file there but it is not because the location is not valid.
0
 

Author Comment

by:seanlhall
ID: 34943890
yes that is the error i get.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 34943910
try this

if dir(me.txtFolderLocation & "",vbdirectory)="" then
   msgbox "Folder does not exists"
   exit sub
   else

    'save file here
end if
0
 

Author Closing Comment

by:seanlhall
ID: 34944034
That was what I was looking for, thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

649 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