Results 1 to 6 of 6
  1. #1
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42

    Run a Function witha Sub statement

    I have a function provided to me by another forum member. It allows me to add notes to a report through an input box by having a text box in the report that has its data property set to = GetNotes().

    Code:
    Function GetNotes()
    GetNotes = InputBox("Enter the notes for  the report " & vbNewLine & "For Ex. This are report notes", "Enter notes")
    End Function
    Unfortunalty, when I put it into a report it runs continuosly. So that I end up having an input box popping up as soon as I close the first one. I would like to have the function only run when a button is clicked. In VB the code to have an action occur on a button click is:



    Code:
    Private Sub Command30_Click()
    End Sub
    Can anybody help set up this function to only run when the botton is clicked?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Private Sub Command30_Click()
    Something = GetNotes()
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42
    But where would I put the code for the function "GetNotes"?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Typically in a standard module so you can call it from anywhere.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42
    thank you, your assistance is greatly appreciated.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  2. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  3. DCOUNT function with IN statement
    By dwilson in forum Access
    Replies: 2
    Last Post: 08-12-2011, 09:54 AM
  4. using the and function in a dlookup statement
    By englisap in forum Programming
    Replies: 10
    Last Post: 01-10-2011, 09:53 PM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM

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