![]() | |
![]() |
| | Thread Tools | Display Modes |
#21
| |||
| |||
|
|
Salad <salad (AT) oilandvinegar (DOT) com> wrote in news:i82dnQgpp4sS7ejRnZ2dnUVZ_sqdnZ2d (AT) earthlink (DOT) com: Returns True if I use a drive letter. C:, X:. Same if I add the path. False on folder and filename. Er, what? It should work for folders and not with filename (if you read the actual content of the function, including the parameter name, this should be obvious). What I said. |
#22
| |||
| |||
|
|
Mark <cmd2... (AT) frontiernet (DOT) net> wrote innews:4f002f39-b3b5-419d-9bdb-23c50e55d2dd (AT) j8g2000yqd (DOT) googlegroups.com : On Aug 25, 5:23*pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: Mark wrote: On Aug 25, 3:35 pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: Mark wrote: On Aug 25, 3:13 pm, "David W. Fenton" NoEm... (AT) SeeSignature (DOT) invalid> wrote: Mark <cmd2... (AT) frontiernet (DOT) net> wrote innews:46c7d84a-3b63-4baa-87c0-5 20fb0615... (AT) 5g2000yqz (DOT) googlegroups.com: Having said all that, I recognize your expertise, so I would like to replace Dir() with your function. Do I simply copy/paste your function into my form and then replace "If Len(Dir(ServerRomney)) 0 Then" with: "If CheckForNetwork(ServerRomney) Then" Yes -- that's all you have to do. I'd suggest pasting the function into a public module, instead of into the form module, so you can use it elsewhere should you decide it's useful. -- David W. Fenton * * * * * * * * *http://www.dfenton .com/ contact via website only * *http://www.dfenton.com/DFA/ Thanks David, I was just now trying this out. I first pasted the function in a form's module and then tried: ?CheckForNetwork("C:\Access97\fpsdata.mdb") in the Immediate window. I got an error: "undefined sub or function". I then pasted the code into a public function (removing the word "Private") and did the ? CheckForNetwork("C:\Access97\fpsdata.mdb") again in the Immediate window. This time it reported "False". I had been expecting "True". Am I missing something? Mark Works for me. *Returns True if I use a drive letter. *C:, X:. *Sa me if I add the path. False on folder and filename.- Hide quoted text - - Show quoted text - Yes, Salad, same for me (but I'm not sure what you mean by "path"). I get the following results: ?CheckForNetwork("C:\") and ?CheckForNetwork("P:\") = True ?CheckForNetwork("C:\Access97") and ?CheckForNetwork("P:\Access97") False ?CheckForNetwork("C:\Access97\fpsdata.mdb") and ?CheckForNetwork("P: \Access97\fpsdata.mdb") = False C:, Y:, works D:\Test or D:\Test\ works D:\Test\Test.mdb doesn't. Path are the folders. *C:\Test1\Test2\Test3 is a folder path IMO.- Hide *quoted text - - Show quoted text - Thanks, Salad At least on your system, the code works for identifying the existance of a folder (D:\Test). This is by design -- the code was written to check for the existence of a FOLDER. If you read the code, that's quite clear. If you want to change it to check for a file, change: * CheckForNetwork = objFSO.FolderExists(strFolderToCheck) ...to: * CheckForNetwork = objFSO.FileExists(strFolderToCheck) I don't think I'd alter this particular function, but create a new one that does the same thing, like this: Public Function CheckForFile(strFileToCheck As String, _ * * *Optional bolClear As Boolean = False) As Boolean * Static objFSO As Object * If bolClear Then Set objFSO = Nothing: Exit Function * If objFSO Is Nothing Then * * *Set objFSO = CreateObject("Scripting.FileSystemObject") * End If * CheckForFile = objFSO.FileExists(strFileToCheck) End Function This will check for the existence of the file instead of for the existence of a folder. [] ... I was able to do some more testing on the main problem. On an Access2007/Win7 computer which had just been rebooted, I clicked the button to open the form in question and there was a delay of approximately 15 seconds. When I moved the cursor above the Access window it turned into the spinning hourglass. Otherwise, it looks like nothing is happening, plus I think the delay may be even longer on some Access2007/Win7 computers. Opening a "Please wait" popup form might be useful. Why don't you put some Debug.Print Now() statements in the code that's opening the form (e.g., the form's OnOpen event, for instance). Anyhow, once I waited long enough for the form to open, I could now open and close the form at will and each time the form would open with no delay at all. Same if I closed and reopened the database -- no delay in opening the form. I also closed that database and opened a mirror copy of the FE, but which is linked to a different BE. When I tried to open the form on that FE it also opened immediately. What code is running when that form opens? Is the form bound or unbound? I thought I had it figured out -- that something in Win7 and/or Access 2007 had to be initialized each time the computer is restarted in order for that particular bit of code to work -- Len(Dir(path)). So, I restarted the computer, opened the database and, guess what, the form opens immediately the first time I click the button. Go figure. That was my guess, too, that the network initialization was the cause of the slowdown, and I thought the File System Object network functions were more efficient. I provided a non-equivalent function, though. I wonder if you rebooted the "server" if you'd have the same time delay opening the form. -- David W. Fenton * * * * * * * * *http://www.dfenton.com/ contact via website only * *http://www.dfenton.com/DFA/- Hide quoted text - - Show quoted text - |
#23
| |||
| |||
|
|
David W. Fenton wrote: Salad <salad (AT) oilandvinegar (DOT) com> wrote in news:i82dnQgpp4sS7ejRnZ2dnUVZ_sqdnZ2d (AT) earthlink (DOT) com: Returns True if I use a drive letter. C:, X:. Same if I add the path. False on folder and filename. Er, what? It should work for folders and not with filename (if you read the actual content of the function, including the parameter name, this should be obvious). What I said. |
![]() |
| Thread Tools | |
| Display Modes | |
| |