Results 1 to 6 of 6
  1. #1
    Robert2150 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    102

    Running a module from cmd button

    I have a module in my database named "modScanner" to scan items into the database.
    Here is the module code:

    Option Compare Database
    Option Explicit

    Public Sub GetImage()
    Dim FileLocation As String
    Dim diagFile As FileDialog
    Set diagFile = Application.FileDialog(msoFileDialogSaveAs)

    diagFile.Title = "Save PDF File As..."
    diagFile.InitialFileName = "*.pdf"

    If diagFile.Show Then
    FileLocation = diagFile.SelectedItems(1)

    Dim scanDiag As Object
    Dim image As Object

    Set scanDiag = CreateObject("WIA.CommonDialog")
    Set image = CreateObject("WIA.ImageFile")

    Set image = scanDiag.ShowAcquireImage()

    image.SaveFile FileLocation

    End If
    End Sub



    How do I get the module to run when clicking a cmd button?

    Thank you in advance for any help.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    in the button click event just put

    GetImage

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    And for clarity, you don't run the module, you run the functions/subs contained within it, as Ajax showed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Robert2150 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    102
    Thanks,

    I was able to get it to run with:

    Private Sub ScanPlans_Click()
    modScanner.GetImage
    End Sub

    Thanks for your help.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    GetImage

    by itself didn't work? I don't think I've ever specified the module name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    If you had to prefix with the module name to get it working, then it suggests you have another GetImage procedure elsewhere.
    Use a unique name for each Public Sub/Function and the module name isn't required.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Running a Module - Keep getting Errors
    By griztkojr in forum Modules
    Replies: 20
    Last Post: 04-20-2018, 01:35 PM
  2. Running a module from a button click
    By adacpt in forum Modules
    Replies: 4
    Last Post: 12-03-2012, 01:09 PM
  3. Running a module from a button in a form
    By sardamil in forum Modules
    Replies: 3
    Last Post: 05-01-2012, 10:59 PM
  4. Running a module
    By KevinMCB in forum Modules
    Replies: 2
    Last Post: 03-09-2011, 02:38 PM
  5. Running module from Macro
    By Harley Guy in forum Modules
    Replies: 6
    Last Post: 10-27-2010, 11:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums