|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Determine if file is available
I’ve posted a similar question but…
What I’m looking for is a way to see if a file is available and if so, run a macro; otherwise, if not available, display a message stating such. I want to click a button on a form that will run some routine to see if “z:\database\sidewalks.mdb” is available. If yes, then run a macro called “macTransfer”; if not available, display a message “Network file is not available”. Thanks, SKK |
|
#2
|
||||
|
||||
|
place the following function in one of your module
Public Function FileExists(Pathname, Filename) As Boolean If Dir(Pathname & Filename) = Filename Then FileExists = True Else FileExists = False End If End Function and now you can place the following command on any event. If FileExists("C:\", "SAI.TXT") Then 'DO SOMETHING ELSE 'DO SOMETHING ELSE ENDIF
__________________
V.Subramanian |
|
#3
|
||||
|
||||
|
The example only checks if the file is present, but we had a case where periodically the Jet DB Engine didn't allow MS Access to be run, while the ASP page remained functioning and database remained present.
We solved it with a different solution, which checked if there was a successful connection: Code:
<% Set conn =Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.Oledb.4.0;data source ="&Server.MapPath("/database/test.mdb")
IF Conn.Errors.Count>0 or conn.state <> 1 THEN %>
<p align="center"><a href="back.asp">something went wrong<br /><br /><br />
Go back and try again</a></p><%
Else
'other stuff for good connection like your macro
End If %>
|
|
#4
|
|||
|
|||
|
Thanks all,
SKK |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Determine if file is available |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|