Taking and storing pictures faster

J

Joe

Hi

I have a form which I can link pictures that are previously stored on my
computer, just like Northwind.

But I wonder if I can have a button which I can press, take a picture, and
instantly my pic would be linked to the record I'm on?

I know I can make a button open my webcam software, but afterwards I need
another button to "manually" link the pic to the record. Is there a way I can
simplify this?

Thanks in advance for any ideas :)
 
K

Klatuu

The only thing I can think of would be to use your form to control that. Use
the form's timer event so it periodically checks for a new file in the folder
where the pictures are stored and when one is detected, use the new file name
to link to the picture.
 
J

Joe

Sounds interesting, any ideas how to do this? And just FYI, Im running access
2007. And what I have in mind is just like an employee database, in which I
have to take a pic of the person and store it in his record.
 
K

Klatuu

I would suggest using two different subfolders in one Pictures folder. One
for pictures not yet added to the database and one for those already added.

It would be like
c:\pictures
c:\pictures\new
c:\pictures\filed

Then in the time event, use the Dir function to see if a new file is in the
new folder and if so, add its name to the database, then use the Name
statement to move the file to the filed folder

Const conSourcePath As String = "c:\pictures\new\"
Const conDestPath As String = "c:\pictures\filed\"
Dim strFileName As STring

strFileName = Dir(conSourcePath)
If strFileName <> vbNullString Then 'New Picture Found
Name conSourcePath & strFileName As conDestPath & strFileName
Me.txtPictureFile = conDestPath & strFileName
End If
 
J

Joe

Ok, sounds great, Ill try it out. Just one more question, if there's a
filename that already exists on the "filed" folder, how can I prevent it to
be overwriten? I suppose you can come up with a code to change the name (like
adding a number) to the filename? so nothing will be overwriten but renamed
instead if aplicable?
 
K

Klatuu

That would be a reasonable thing to do. You could use the Dir function to
check for the existance of the file and if found, rename the file:

Const conSourcePath As String = "c:\pictures\new\"
Const conDestPath As String = "c:\pictures\filed\"
Dim strFileName As String
Dim strCheckFile As String
Dim lngFileNo As Long

strFileName = Dir(conSourcePath)
If strFileName <> vbNullString Then 'New Picture Found
strCheckFile = Dir(conDestPath & strFileName)
Do While strCheckFile <> vbNullstring
lngFileNo = lngFileNo + 1
strFileName = strFileName & Format(lngFileNo, "00")
strCheckFile = Dir(conDestPath & strFileName)
Loop

Name conSourcePath & strFileName As conDestPath & strFileName
Me.txtPictureFile = conDestPath & strFileName
End If
 

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

Top