Add Filepath (1 Viewer)

tucker61

Registered User.
Local time
Today, 09:02
Joined
Jan 13, 2008
Messages
324
I have a form with a button (Code below) that allows people to add a link to a attachment which is stored on our server.

Problem is people are not the brightest and tend to link to files that are on their desktop (so no one else can open them)

How can i change the code below so it checks the filepath is correct before allowing them to create the link ?

The file should always be placed in the "\\Retail" folder

So is it possible to insert a Left Function in the below ? to check
Code:
if (Left(filepath,4) <>"\\Re"
if so, where would i put this without upsetting the For statement ?

Code:
Private Sub btnAdd_Click()
Dim f As Object
Dim i As Integer
Dim TimeNow As Date
    Set f = Application.FileDialog(3)
    f.InitialFileName = "\\retail\"
    f.AllowMultiSelect = True
    f.Filters.Clear
    f.Filters.Add "Attachment", "*.msg,*.jpg;*.jpeg;*.gif;*.bmp;*.png;*.tif;*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.mp4,*.mov"
    f.show
    For i = 1 To f.selecteditems.Count
           WaitOn "Adding " & i & " of " & f.selecteditems.Count
        CurrentDb.Execute "INSERT INTO tblQCfiles ( Job_ID, Date_Added, File_Location ) " & _
                          "SELECT " & Forms!frmmain.tbJobID & ", Now(), '" & f.selecteditems(i) & "' AS Expr1;"
    TimeNow = Time
    Do While Time < DateAdd("s", 1, TimeNow)
        DoEvents
    Loop
    Next i
    Me.Requery
    Waitoff
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:02
Joined
Aug 30, 2003
Messages
36,125
Right after the For line you could add:

Code:
If Left(f.selecteditems(i), 4) <> "\\Re" Then
  MsgBox "Must select files on server"
  Exit Sub
End If
 

Users who are viewing this thread

Top Bottom