Uploading a Picture

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I have an Issue Tracking Database. On the issue entry form I have placed a
button that opens the standard file dialog box. The user can then select a
picture on from their computer and a copy will be placed on the network
drive. This is probably a simple question but I'm new to access. After the
user selects the file they want, I need a Yes/No field in my table to become
Yes. This way I can track what issues have photos with them. Here is the code
I have, any help would be appreciated.

Dim strFilter As String
Dim lngFlags As Long
Dim picLocation As String
Dim picDest As String
Dim fsObj As Object
Dim recordNum As Long

strFilter = ahtAddFilterItem(strFilter, "Picture Files (*.jpg, *.bmp)",
"*.JPG;*.BMP")

picLocation = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Select photo to attach")


' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)

If picLocation <> "" Then
recordNum = Form.CurrentRecord
picDest = "S:\QUALITY\Photos\Pic." & recordNum & ".jpg"

Set fsObj = CreateObject("Scripting.FileSystemObject")
fsObj.CopyFile picLocation, picDest
Set fsObj = Nothing

MsgBox ("Photo Succesfully Uploaded!")

Else
MsgBox ("No Photo Selected")
End If

Thanks in advance
 
OK, I figured something out. I just added a check box on the bottom of my
form linked to the record in the table and disabled it. Then when the user
selects the picture I change the value on the text box. So for anyone else
wondering...just add a check box and 1 line of code

chkPhoto = True
 
Back
Top