Uploading a Picture

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
 
B

Brad

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Copying a File using API 1
Attach File 4
code problem 6
attachment 9
Stripping file name from Path... 2
API Open Dialog. What if user cancels 1
Error 13 Type Mismatch HELP!!! 1
Folder access (Access 2003) 1

Top