Results 1 to 9 of 9
  1. #1
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45

    Question Help Please in File checking status

    hello, i am using the following code to get the status of a file in diferents folder, but i dont how figure out how load the vba code to load auto for all records. I was testing in command click event and work, but where put this to load without user intervention. I was trying in Form load, also in Form current , but nothing... and the end what I need is the system check in my folder if the file exist or not, an show a text document exist or doc missing

    this is the code I am using:

    Dim filename As String
    Dim filepath As String


    Dim cname As String
    Dim missinvalue As String
    Dim docexist As String

    docexist = "Doc. Exist"
    missinvalue = "Doc. Missing"
    cname = Forms![ContractorsDBForm]![Text442]
    filename = Me.DocumentsName & ".pdf"
    filepath = DLookup("[ContractorPath]", "querysetup") & cname & DLookup("[expr1]", "querysetup") & cname & " " & filename
    If Dir(filepath) = "" Then
    Me.MissDoc = missinvalue
    Else
    Me.MissDoc = docexist
    End If



    thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Code:
    if FileExists(filepath) then
        Me.MissDoc = missinvalue
    else
        Me.MissDoc = docexist
    endif
    put this in public module:


    Code:
    Public Function FileExists(ByVal pvFile) As Boolean
    Dim FSO
    Set FSO = CreateObject("Scripting.FileSystemObject")
    FileExists = FSO.FileExists(pvFile)
    Set FSO = Nothing
    End Function

  3. #3
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Thanks, i follow but code show me EXPECT VARIABLE OR PROCEDURE, NOT MODULE.

    I put this code in my form load, it is ok?

    Private Sub Form_Current()
    Dim filename As String
    Dim filepath As String
    Dim cname As String
    Dim missinvalue As String
    Dim docexist As String
    cname = Forms![ContractorsDBForm]![Text442]
    filename = Me.DocumentsName & ".pdf"
    filepath = DLookup("[ContractorPath]", "querysetup") & cname & DLookup("[expr1]", "querysetup") & cname & " " & filename
    If FileExists(filepath) Then
    Me.MissDoc = missinvalue
    Else
    Me.MissDoc = docexist
    End If

    End Sub

  4. #4
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you didnt show WHERE the error happened.

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Add the debug.print to see if you have a valid filepath.
    Code:
    docexist = "Doc. Exist"
    missinvalue = "Doc. Missing"
    cname = Forms![ContractorsDBForm]![Text442]
    filename = Me.DocumentsName & ".pdf"
    filepath = DLookup("[ContractorPath]", "querysetup") & cname & DLookup("[expr1]", "querysetup") & cname & " " & filename
    debug.print filepath
    If Dir(filepath) = "" Then
        Me.MissDoc = missinvalue
    Else
        Me.MissDoc = docexist
    End If
    Last edited by davegri; 07-17-2018 at 07:10 AM. Reason: format

  6. #6
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Hello thanks foir help.,

    the debug print retunr a valid path,

    now the problem is tha form reapit same value in all file. if first is misssing the reat are misssing too, but document exist

    that i must to put the code in Form current event?

  7. #7
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Click image for larger version. 

Name:	Screen Shot 07-17-18 at 10.00 AM.jpg 
Views:	8 
Size:	163.9 KB 
ID:	34753

    see the image

  8. #8
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Hello, errorr happend when load form

    thanks

  9. #9
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Hello, THe only method I can obtain the field update is making click in each record on the subform to update the status, nothin more work , in form load or form current just the first field update on my continuous sub form. my code is as show bellow:

    Private Sub MissDoc_Click()
    docexist = "Doc. Exist"
    missinvalue = "Doc. Missing"
    cname = Forms![ContractorsDBForm]![Text442]
    filename = Me.DocumentsName & ".pdf"
    Filepath = DLookup("[ContractorPath]", "querysetup") & cname & DLookup("[expr1]", "querysetup") & cname & " " & filename
    If Dir(Filepath) = "" Then
    Me.MissDoc = missinvalue
    Else
    Me.MissDoc = docexist

    End If
    End Sub



    please any idea how update all field in my continuous subform

    thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Execution of code dependent on outside file status
    By stephen c in forum Programming
    Replies: 2
    Last Post: 05-01-2017, 04:14 PM
  2. checking for end of file
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 04-15-2016, 04:14 PM
  3. Replies: 2
    Last Post: 10-29-2013, 09:31 AM
  4. Replies: 4
    Last Post: 06-20-2013, 10:26 PM
  5. Checking beforehand whether a file exists
    By Ronald in forum Programming
    Replies: 2
    Last Post: 07-27-2011, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums