Solved

Scanning images with MS Access form using VSTwain ActiveX by VintaSoft

Posted on 2015-02-05
12
230 Views
Last Modified: 2016-02-11
Hello All,

Is it possible to preview the scanned document in the image1.Picture before saving? I've been successful at scanning and saving to a folder on the server. When I navigate record to record the images do load correctly.

I would like to scan the image, display it before saving on the form, and then have the user continue by clicking "Save" or cancel.

Here is what I have so far:
'Scan Button

Private Sub BAcquire_Click()

Dim User As String
Dim Email As String
Dim RegCode As String
Dim Result As Long

   
    User = "xxxxxxxx"
    Email = "jheilman@xxxxxxxxx.com"
    RegCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    Result = VSTwain1.Register(User, Email, RegCode)

    VSTwain1.StartDevice
         If VSTwain1.SelectSource = 1 Then
            VSTwain1.autoCleanBuffer = 1
            VSTwain1.maxImages = 1
            VSTwain1.showUI = 1
            VSTwain1.Acquire
        End If

'Set Image1.Picture = VSTwain1.GetCurrentImage <<<<< I haven't been able to get this to work.  I get an "Invalid Use of Property" error.
           
 End Sub

'Save Button

Private Sub SaveScan_Click()
Dim flag As Long
Dim strFileName As String

 strFileName = Me.txtstrFileName

    If flag <> 0 Then
        If VSTwain1.errorCode <> 0 Then
            MsgBox VSTwain1.ErrorString
        End If
    Else
               
          VSTwain1.TiffCompression = 1
          If (VSTwain1.SaveImage(0, "q:\Downstream\" & strFileName) = 1) Then
          MsgBox VSTwain1.ErrorString
          End If
            
      '      Dim fName As String
       '     fName = "Q:\Downstream\" + Me!strFileName
        '    VSTwain1.SaveImage 0, fName
                    
         '  If VSTwain1.errorCode <> 0 Then
          '      MsgBox VSTwain1.ErrorString
           ' Else
            '    Me![Link] = fName
             '   Me![Image1].Picture = fName
            End If
        'End If
    'End If
    Me.Image1.Requery
    
End Sub

Open in new window


ScanDocumentForm.jpg
0
Comment
Question by:jeff-h
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40591843
Clearly define what you mean by "saving" the image?
Saving the image to an OLE field? an Attachment field, ...Save just the Path...
(I would save the path)

On overall concept wold be to:
Scan it and save it to a disk file. (this is the easiest way to "View" the image)
Store the path to the image as a variable
Then display the image file based on the path variable.
If it appears the way you like, *Then* save the path variable to he record

I am not familiar with your code, ...but from what you posted, I am sure you can get something going based on my suggestion.

FWIW, Did you look into this product:
http://www.ammara.com/dbpix/access.html

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40591860
...oh and if the image is not what you wanted,...then you can delete the file with code like this:
 Kill "c:\YourFlder\YourFile.jpg"

Or
Kill strTempImagePath
...If you saved the path to a variable named: strTempImagePath

If you get errors using"Kill", then you will have to use the windows scripting library to issue a Delete file command.
0
 

Author Comment

by:jeff-h
ID: 40591862
Hi Jeff!  I'm saving the images to a share on our network as .tif files and writing the path to each .tif in a table.

How would I go about saving the scanned image to a local temp file, loading that into the Image1 control, and then if satisfied save it to the network share?

Thanks for your time,
Jeff
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:jeff-h
ID: 40591873
OK, I'll do the kill thing, I've used it before.  Great idea!  I still can't get the image just scanned to load after saving though.  I don't work with images a whole lot.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40591910
What does the code you posted do currently?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40591915
I am sure another Expert can chime in with how to save an image to a disk file.
But, as for me, I use the utility I posted the link to:
http://www.ammara.com/dbpix/access.html
0
 

Author Comment

by:jeff-h
ID: 40591920
Right now the code fires up the scanner, scans the image, and saves it as a .tif to a folder on the network.  I've gotten the KillFile procedure you suggested working.  All I have to do now is have the image load into the Image1 control after it is saved.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40592010
Saddly Tif/tiff images cannot be displayed in a standard Access image control(s)
...Can you use the .jpg or .png formats instead?

Then the code would be something like this:
Me.YourImageControl.Picturel="C:\YourFolder\YourFile.jpg"

...or if you store the path as a variable:
Me.YourImageControl.Picture=strImagePath
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 40592068
sorry for the typo, ...the first code should be:

Me.YourImageControl.Picture="C:\YourFolder\YourFile.jpg"
0
 

Author Closing Comment

by:jeff-h
ID: 40592262
Thanks for your help Jeff, you managed to get the wheels in my brain turning again.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40592308
Jeffs helping Jeffs...
;-)
0
 

Author Comment

by:jeff-h
ID: 40592324
LOL, that made me think of organizing a big "JeffAid" concert to benefit hack developers like myself.  I want ZZ Top and Motorhead to headline.  Thanks again, it's been fun.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question