Control the Computer Camera using a command from Access 2016 (1 Viewer)

gstylianou

Registered User.
Local time
Today, 08:32
Joined
Dec 16, 2013
Messages
357
Good evening,

I have a database that contains the tables TblCustomers and TblPictures. The tblCustomers table is linked to TblPictures with [CustomerNo]. The TblCustomers is the "One" and the TblPictures the "Many".

In the client data entry form, I would like to be able to call the Computer Camera (Tablet, Laptop, Web Cam) using a command and then automatically to take a picture storing the Path image into TblPictures based on the [CustomerNo].

Is this possible? I mean is there a way to hava full control on the computer camera through Access;

Thanks in advanced
 

gstylianou

Registered User.
Local time
Today, 08:32
Joined
Dec 16, 2013
Messages
357

JHB

Have been here a while
Local time
Today, 07:32
Joined
Jun 17, 2012
Messages
7,732
..
Is this possible? I mean is there a way to hava full control on the computer camera through Access;
I've done it back in the late nineties when WEBcam began to appear, but I've to write my own dll, (written in Delphi), if it still works I don't know because I don't have WEBcams anymore.
Maybe there are some of the other members here who have also played with webcams and have a better solution.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:32
Joined
May 7, 2009
Messages
19,229
use AccessImagine, or
a small utility called RoboEyez
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,209
If you just want to open the webcams software by clicking a button in Access that's certainly possible

One way is using the Shell command:

Code:
Public Sub ShellEx(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean) 'CR v5186

    If Dir(Path) > "" Then
        apiShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
    Else
        MsgBox "Can't find program"
    End If

End Sub

2 random examples of this:

Code:
Public Function OpenNotepad() 

    Call Shell("NOTEPAD.EXE", 1)

End Function


Public Function OpenMagnifier() 

    ShellEx "c:\windows\system32\magnify.exe", , 0

End Function
 

gstylianou

Registered User.
Local time
Today, 08:32
Joined
Dec 16, 2013
Messages
357
If you just want to open the webcams software by clicking a button in Access that's certainly possible

One way is using the Shell command:

Code:
Public Sub ShellEx(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean) 'CR v5186

    If Dir(Path) > "" Then
        apiShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
    Else
        MsgBox "Can't find program"
    End If

End Sub

Dear friend riiders,

How can i call this code from a button? (sorry for a maybe stupid question but i'm not expert in vba)
 

Lightwave

Ad astra
Local time
Today, 06:32
Joined
Sep 27, 2004
Messages
1,521
This is the process in Access 2003 but its almost exactly the same in all versions of Access.

Open the form you wish to have the button on in Design Mode.

Using the form toolset select "button" and use the mouse to draw its outline on your form.

Right click on button and select Properties.

A windows dialog should appear relating to the selected button. Scan down the different options and place the cursor in the white field next to On Click

A small button should appear to the right of the white field with three dots within. Use your mouse to hit it.

A further dialog box will appear titled Choose Builder
Select Code Builder and then OK

You should now be in the VB Code builder window where you can cut and paste (or straight type your code. You need to place it in the sub routine relating to the name of your button.

Once saved and exited and running the form any code should run when the button is clicked. There are other options for what event triggers the code - on click is the most widely used.
 

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,209
Following on from Lightwave's very detailed explanation, you need to put the ShellEx code from post #8 in a standard module.

The click event code for a button called cmdMagnifier would then be this:

Code:
Private Sub cmdMagnifier_Click()
     ShellEx "c:\windows\system32\magnify.exe", , 0
End Sub

This calls the ShellEx routine and specifies the program path & conditions to be used

Or if you intend to run the same code from more than one place, also put the OpenMagnifier function in the standard module and you can call it from anywhere. So your button code can be:

Code:
Private Sub cmdMagnifier_Click()
     OpenMagnifier
End Sub
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 06:32
Joined
Jan 14, 2017
Messages
18,209
Apologies, to use the code in my last reply you also need additional Windows API code to allow the ShellEx function code to work.

Lets do a simplified version instead just using the standard Shell function.
No module code needed

This opens the calculator from a button on a form

Code:
Private Sub cmdCalc_Click()
     Call Shell ("c:\windows\system32\calc.exe", 1)
End Sub

or for Notepad

Code:
Private Sub cmdCalc_Click()
     Call Shell ("c:\windows\notepad.exe", 1)
End Sub

In the last example , you can omit the full path as its in the main Windows folder. So this also works

Code:
Private Sub cmdNotepad_Click() 
    Call Shell("notepad.exe", 1)
End Sub

HTH
 

Users who are viewing this thread

Top Bottom