Results 1 to 6 of 6

Running a module from cmd button

  1. #1
    Robert2150 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    94

    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
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    6,313
    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
    18,948
    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
    www.BaldyWeb.com

  4. #4
    Robert2150 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Location
    Sparks, Nv
    Posts
    94
    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
    18,948
    GetImage

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

  6. #6
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,471
    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 (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

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, 12:35 PM
  2. Running a module from a button click
    By adacpt in forum Modules
    Replies: 4
    Last Post: 12-03-2012, 12:09 PM
  3. Running a module from a button in a form
    By sardamil in forum Modules
    Replies: 3
    Last Post: 05-01-2012, 09:59 PM
  4. Running a module
    By KevinMCB in forum Modules
    Replies: 2
    Last Post: 03-09-2011, 01:38 PM
  5. Running module from Macro
    By Harley Guy in forum Modules
    Replies: 6
    Last Post: 10-27-2010, 10: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
  •  
Tech Forums: Microsoft Office Forums