2003 not behaving like 2007 problem ??

scoob8254

Registered User.
Local time
Today, 10:34
Joined
Mar 2, 2008
Messages
76
hello, i run a small app to manage various stuff to do with our server, im running access 2007 and a friend of mine is running access 2003

i have some code that downloads logs from a remote location if they are present, theirs a small bit of code that test whether its downloaded any and if they are present in the local logs dir, the code is
Code:
If FileExists("C:\Snipers MS2\logs\*.*") = False Then
   MsgBox ("No New Logs")
   Exit Sub
End If
my friends access 2003 gets the logs, the logs are present in the logs dir but he still gets the no new logs message, even tho they are present

mine running access 2007 runs fine with ni problems, im guessing its a problem with the FileExist module, the code for that is here
Code:
Option Compare Database
Function FileExists(ByVal strFile As String, Optional bFindFolders As Boolean) As Boolean
'Purpose: Return True if the file exists, even if it is hidden.
'Arguments: strFile: File name to look for. Current directory searched if no path included.
' bFindFolders. If strFile is a folder, FileExists() returns False unless this argument is True.
'Note: Does not look inside subdirectories for the file.
'Author: Allen Browne. http://allenbrowne.com June, 2006.
    Dim lngAttributes As Long
    'Include read-only files, hidden files, system files.
    lngAttributes = (vbReadOnly Or vbHidden Or vbSystem)
    If bFindFolders Then
        lngAttributes = (lngAttributes Or vbDirectory)    'Include folders as well.
    Else
        'Strip any trailing slash, so Dir does not look inside the folder.
        Do While Right$(strFile, 1) = "\"
            strFile = Left$(strFile, Len(strFile) - 1)
        Loop
    End If
    'If Dir() returns something, the file exists.
    On Error Resume Next
    FileExists = (Len(Dir(strFile, lngAttributes)) > 0)
End Function

Function FolderExists(strPath As String) As Boolean
    On Error Resume Next
    FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
End Function

Function TrailingSlash(varIn As Variant) As String
    If Len(varIn) > 0 Then
        If Right(varIn, 1) = "\" Then
            TrailingSlash = varIn
        Else
            TrailingSlash = varIn & "\"
        End If
    End If
End Function
can anybody suggest a solution so works on 2003 as well as 2007

scoobs
 
Last edited by a moderator:
Post the code that displays the "No new logs" message
 
i did in my first post, the bit of code that displays the message is first followed by the code for the module that actualy checks
 
I'm guessing these log files are TXT documents? What you should be doing is specifying what type of file you are looking for. So instead of:

If FileExists("C:\Snipers MS2\logs\*.*") = False Then

You do this:

If FileExists("C:\Snipers MS2\logs\*.txt") = False Then

If that doesn't work, also try using the Dir() function like this:

If Dir("C:\Snipers MS2\logs\*.txt") = "" Then
 
There should be absolutely nothing wrong with this code.

My guess, user error, wrong folder/subfolder/drive something...
 
my first guess was user error, but ive been through it time and time again with him and he swears hes got the dir's setup correctly, ill try all your suggestions and report back

cheers
scoobs
 
just changed my code to this
Code:
If Dir("C:\Snipers MS2\logs\*.log") = "" Then
       MsgBox ("No New Logs")
       Exit Sub
    End If

tested it works perfect on my access 2007, my friend still has same problem, still gets message "no new logs" even though their is definatly logs in C:\Snipers MS2\logs\ to process..

realy getting on my nerves now lol

could it be a secuity setting he has ?

scoobs
 
Not sure. Maybe somehow the logs aren't visible to the function. Try this:

If Dir("C:\Snipers MS2\logs\*.log", vbNormal + vbReadOnly + vbHidden) = "" Then
 
Another thing to check -

Does his settings have the "Hide Extensions for Known File Types" set to YES? If so, change that to NO. (it is in Windows Explorer under TOOLS > FOLDER OPTIONS > VIEW.
 
right thanks guys, the hide know file types seems to have doine the trick

thanks a lot :)

scoobs
 
Cool, glad we could help. That one just popped into my head after a LOT of thought about what was happening but it was vbaInet's comment:
vbaInet said:
Maybe somehow the logs aren't visible
which was the trigger. :)
 

Users who are viewing this thread

Back
Top Bottom