+ Reply to Thread
Results 1 to 5 of 5

Call passing variables

  1. #1
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Call passing variables

    Please Login or Register  to view this content.

    The above code is from a form with many OptionButtons on it. I need to pass the varible "month" to another Public Sub called "Main". This is not happening.

    Below is the main proc.
    Please Login or Register  to view this content.

    Any idea guys?
    Last edited by VBA Noob; 12-17-2006 at 03:47 PM.

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Hi Zrx,

    You have a couple of options on how to pass "month", but there is one absolute requirement ... namely, your Main routine needs to be ready to accept it.

    You could use any of the following declaration statements for Main:

    Please Login or Register  to view this content.
    Using "Optional" means that the "calling" routine can (but does not have to) pass "month" to "Main". To use the "optional" option, you would need to re-write Main to work either with or without "month" being passed.

    The byRef and byVal determine whether or not Main can change "month". In this case it does not matter because calling Main is the last thing your form does (right?).

    The calling statement can look like either of these:

    Please Login or Register  to view this content.
    Oh ... one other thing ... month must be dimensioned exactly the same in both routines. So, if you use "month As String" in the declaration of Main, then you must use "Dim month As String" in the calling routine.

    Hope this helps.

  3. #3
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    call procedure

    Quote Originally Posted by MSP77079
    Hi Zrx,

    You have a couple of options on how to pass "month", but there is one absolute requirement ... namely, your Main routine needs to be ready to accept it.

    You could use any of the following declaration statements for Main:

    Please Login or Register  to view this content.
    Using "Optional" means that the "calling" routine can (but does not have to) pass "month" to "Main". To use the "optional" option, you would need to re-write Main to work either with or without "month" being passed.

    The byRef and byVal determine whether or not Main can change "month". In this case it does not matter because calling Main is the last thing your form does (right?).

    The calling statement can look like either of these:

    Please Login or Register  to view this content.
    Oh ... one other thing ... month must be dimensioned exactly the same in both routines. So, if you use "month As String" in the declaration of Main, then you must use "Dim month As String" in the calling routine.

    Hope this helps.

    Okay, thanks for the good explanation.

    I now have the varible passing with one small problem.

    code below:
    Please Login or Register  to view this content.

    Calls to main below

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 12-17-2006 at 03:48 PM.

  4. #4
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Hi Zrx,

    Not completely sure that I follow your logic. If I am reading this correctly, you are launching a form named "novemberstats" from your Main routine, and then you want to change the values in text boxes on that form using code in the Main routine.

    If that is correct, then the problem is that you need to give the full reference to these text boxes, as follows:

    Please Login or Register  to view this content.
    If that does not work, then use this:

    Please Login or Register  to view this content.
    I can never remember when I need to use "Object" in that command. But, the intellisense (selection boxes that appear when you press the ".") should give you the answer to that.

    Hope this helps.

  5. #5
    Registered User
    Join Date
    11-22-2006
    Posts
    80

    Smile calling procedure

    Hello, MSP77079


    I got it working with your help! Yes I needed to put the object ahead of the textbox. Did so in code where needd and it has worked thus far.

    Thanks for your input.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1