Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / May 2005

Tip: Looking for answers? Try searching our database.

If Imported file not available - what to do

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pele - 17 May 2005 14:56 GMT
I have put togetehr an Access application that requires
the USER to click a command button to import data to be
loaded/added to a table. The import macro will ask the
User if he is sure the data is available in the pre-
defined subdirectory in the C:/ drive. If the User says
yes, then the macro goes ahead and imports the file.

The problem arises if the User says yes BUT if the
expected file is not there. The Macro just seems to halt
and then shows the database window.

What can I do to enhance the macro such that, I can handle
situations where the file does not exist in the predefined
directory and the macro gives the focus back to the
switchboard instead of halting. Any help will be
appreciated.

Pele  
Joe Fallon - 18 May 2005 03:39 GMT
Macros do not have error handling.
I recommend you use VBA code instead.
Once you get used to code you won't need to use macros.
In code you can check to see that the file exists and then do something else
if it does not.
Signature

Joe Fallon
Access MVP

>I have put togetehr an Access application that requires
> the USER to click a command button to import data to be
[quoted text clipped - 14 lines]
>
> Pele
Jim - 31 May 2005 15:37 GMT
Joe,

What is/are the command(s) to test to see if a file exists?

Thanks,

Jim

> Macros do not have error handling.
> I recommend you use VBA code instead.
[quoted text clipped - 19 lines]
> >
> > Pele
Joe Fallon - 01 Jun 2005 00:38 GMT
Here is one way:

Add this code to a module:

Public Function FileExists(strPath As String, Optional lngType As Long) As
Boolean
On Error Resume Next
 FileExists = Len(Dir(strPath, lngType)) > 0
End Function

Then anywhere in your code you can call it like this:

If FileExists("C:\mydocs\MyFile.txt") Then
  'do something with the file
End If

Signature

Joe Fallon
Access MVP

> Joe,
>
[quoted text clipped - 28 lines]
>> >
>> > Pele
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.