webcam to capture images and save to file, URGENT!!

I have a web cam im using to show live video in my MS access form, but i want to beable to snap the image and save to file.(sort of like the windows movie maker works , in XP)

so far im using VideoCapFree activex to capture live video.... but how can i take snap shots and save it to .jpg, .bmp.etc?
heres my code:


Option Compare Database

Private Sub Command1_Click()
End Sub

Private Sub Command16_Click()

End Sub

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim Bx, Hwn, Scnav As Boolean
Scnav = ScanControl.ScannerAvailable
Select Case Scnav
Case True

'check for file type being used

DoCmd.GoToControl "piclocation"
If InStr(piclocation.Text, ".bmp") Then
VideoPreview1.FileType = BMP_Bitmap
ElseIf InStr(piclocation.Text, ".awa") Then
VideoPreview1.FileType = AWD_MicrosoftFax
ElseIf InStr(piclocation.Text, ".tif") Then
VideoPreview1.FileType = TIFF
End If

'Uncomment the next line to give user scan preferences

DoCmd.GoToControl "piclocation"
ScanControl.Image = piclocation.Text


'names the file in this case I named it by combining ID and Last Name
Me.Imagepath = Me.NameID & Me.LastName & ".bmp"
Exit Sub

Case False
MsgBox "Scanner is Busy!" + vbCrLf + "Try Again Later.", vbInformation, "Scanner: Busy!"
Exit Sub

End Select
Err_Command2_Click: MsgBox Err.Description

End Sub

Private Sub Command3_Click()
'comment out the next line to select the default cam/scanner
End Sub

please let me know how to add a save image feature..
or if you might know of a better way please let me know!!

I reply quickly~
Sam CohenConsultant to Digital/DeveloperAsked:
Who is Participating?
i'm not familiar with that activex

but ezvidcap works nice

check out

Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Hey Sid, Can you help me out with the code, im a 2 year Beginner to vba
Basically im trying to capture video then click a button to snap frames, and once snapped, save to file with a custom filename..

Thanks in Advance!!!
this is much simpler than what you were trying in the link i posted

Get the file from shrinkwrapvb
unzip file

open a new form

goto the code page, tools > references , register the ocx's (the rest of the files in the zip are inrelevant unless you have VB)

place a vbVidC60.ezVidCap Control on your form (from the More Controls button on your tool bar)

Name the control Vid

create a button called capture

then in the on click event

Private Sub Capture_Click()
Me.Vid.SaveDIB "C:\test.dib"

strSQl = "Insert Into MyTable (ID, CapPath), values (me.SomeID, "C:\test.dib")
execute...blah blah
End Sub

how you do this depends on whether you are are using DAO or ADO

if you are going to do multiple captures from a stream....
set up something to sequentially name the file after each click

you could have multicapture and autorename

Public FilePad
Private Sub Capture_Click()
If IsNull(filePad) Then
   filePad = 1
End If
Me.Vid.SaveDIB "C:\Pic_" & filePad & ".dib"
filePad = filePad + 1
End Sub

to capture a single frame

Private Sub Capture_Click()

CapName = inputbox ("Please Enter CapName")

Me.Vid.SaveDIB "C:\ & CapName & ".dib"
strSQl = "Insert Into MyTable (ID, CapPath), values (me.SomeID, "C:\test.dib")
execute...blah blah
end sub

you could also -prename- the file by creating a text box on your form which the user would fill out prior to clicking the capture button...this way you can capture a file from an active stream...a static stream (say an employee photo from a webcam) doesn't need can use the input box method  

you'll note that the file is a dib format 9device independent bitmap...but access can deal with these no problem

if you need some help with the specific code to insert let me know if you are using DAO or ADO
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Ok i see!
basic i have the filename saving as: ImagePath= CapName & ".bmp"
so therefore i will execute sql: insert into MyTable (imagePath) blah blah
but how do stop the camera from running onload?
I want to be able to start and stop at any time..

when i loaded the activex on to the form and viewed it, it automatically as for the device...-- i dont want this to happen , i want beable to choose my device in the form , with other functions

you can't -stop- the's always could hide it if you want...but it isn't capturing's just in preview mode.

if you read the exVidCap.doc that came with the ocx you will see all of the different methods and properties of the ocx

amoung other things you'll see this

ShowDlgVideoSource returns: Boolean
<takes no parameters>

Displays a dialog box in which the user can control the video source. The Video Source dialog box might contain controls that select input sources; alter the hue, contrast, brightness of the image; and modify the video quality before digitizing the images into the frame buffer.

to use it all you would do is  create a button with a click event


and that will pop up a dialog box to select your source

there's a lot of other settings you can play around with as well

Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Thanks...It works great with my Sony camcorder as well!!!
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Youre the best Sid!!!!
glad to help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.