Results 1 to 3 of 3
  1. #1
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138

    Passing Variables creates more problems

    I am trying to pass a variable (strEventReportSQL) from one Sub to another where it is defined as follows:



    {Originating Procedure}

    Private Sub cboConValue_AfterUpdate()

    Dim strEventReportSQL as String
    ...
    strEventReportSQL = "..."

    End Sub

    {Receiving Procedure}

    Private Sub cmdReportPrint_Click(strEventReportSQL as String)

    ...

    End Sub

    Am I missing something here. I know this is probably an easy fix, could someone just point me in the right direction?
    Thanks.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You will either need to define it as a Global Variable, or call one Sub Procedure from the other, passing the value at that point.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,734
    Dave,
    It would be better if you included all the code for the procedures. However, let me make some guesses as to what you are doing. And these guesses may be opposite to your intentions..., but they represent the second option in JoeM's response.

    If you are calculating a value for strEventReportSQL = "..." in Sub cboConValue_AfterUpdate() and you want to perform/execute procedure Sub cmdReportPrint_Click using the value of strEventReportSQL = "...",then I think you would
    have a statement
    Code:
         Call  cmdReportPrint_Click(strEventReportSQL) 
    

    in your originating procedure , after you have assigned a value to
    strEventReportSQL

    But as I said, I'm guessing at your intent. There is more info here

    Note: The colors aren't meant to confuse. The purple represents a variable, and the blue represents procedures.
    Last edited by orange; 04-05-2013 at 06:42 AM. Reason: spelling/alignment

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

Similar Threads

  1. Look up table creates many relationships is this bad?
    By Leonidsg in forum Database Design
    Replies: 2
    Last Post: 02-19-2013, 12:08 PM
  2. Code Problems With Variables
    By bidbud68 in forum Programming
    Replies: 6
    Last Post: 01-30-2013, 01:37 PM
  3. Replies: 7
    Last Post: 12-29-2011, 03:12 PM
  4. Reports and variables, problems
    By _Boo in forum Reports
    Replies: 3
    Last Post: 06-23-2011, 01:08 PM
  5. Passing variables to a Word Doc.
    By techexpressinc in forum Forms
    Replies: 2
    Last Post: 09-16-2010, 01:04 PM

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