Results 1 to 12 of 12
  1. #1
    nichojo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    10

    How to pass what was clicked to module?

    I have a module that takes a string parameter. I have a report that lists all the reports in the database (ironic, right?). When one of those reports is clicked, I want to pass what was clicked to that module. What do I list as the parameter when generating the onclick event?



    Am I doing this all wrong?

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    So are the report names set up as hyperlinks on the report?

  3. #3
    nichojo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    10
    No, but that should be easy enough- Is that a good start?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Well I am trying to figure out how you are obtaining a value for the string clicked. However, I think a button would be better. If you assigned each command button the value you want to pass you could pass the value to the module with each "On Click" event on the command button.

  5. #5
    nichojo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    10
    That's the question - how to obtain the value of what was clicked. With a basic event procedure I can end up with:

    Private Sub Name_Click()

    End Sub

    OR

    I can just do a runCode and run the module I specified. I just need to figure out how to tell me module the value of the object that was clicked.

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I would set up a variable for each report.

    varReport1 = "Report name"
    varReport2 = "Report name 2"

    Command1_OnClick()
    pass varReport1 to module
    end sub

    Does that make sense? Is that what you are trying to accomplish or do you want to stay away from variables?

  7. #7
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    You could also use Labels and use the on click event for the lable and just pass the label.caption value.

  8. #8
    nichojo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    10
    The report list is dynamically generated via a query so I cannot use either method. Thanks for the tips though.

  9. #9
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Ok, I understand now...

  10. #10
    nichojo is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    10
    Figured it out. MsgBoxMe is my text function that just displays what it is passed:

    Name being the textbox that contains the report name.

    =MsgBoxMe([Report]![Name].[Text])

  11. #11
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I just tested a dynamic report. If you populate the report names in a text box you can use the textbox value in the on click event to pass to your module. I have included some sample code that simply displays in a message box which confirms you can get the value even if dynamic

    Code:
    Private Sub Text2_Click()
    MsgBox Text2.Value, vbOKOnly
    End Sub

  12. #12
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    You can use Text2.value and pass that to your module in the "On Click" event of the textbox.

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

Similar Threads

  1. need help with import Module
    By marubal21 in forum Modules
    Replies: 1
    Last Post: 07-22-2010, 12:23 AM
  2. Replies: 6
    Last Post: 04-23-2010, 06:43 AM
  3. Replies: 1
    Last Post: 01-29-2010, 11:30 AM
  4. Module not found
    By nooby in forum Modules
    Replies: 1
    Last Post: 12-02-2009, 02:20 PM
  5. Replies: 6
    Last Post: 09-26-2009, 07:17 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