+ Reply to Thread
Results 1 to 4 of 4

Using a call procedure

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    237

    Question Using a call procedure

    I've got a userform that calls a procedure based on the info entered. The problem I'm having is that my form defines items but the sub procedure isn't recognizing what was defined. I'm attaching a file with the form in it. Look at the Accrued PTO form. It defines facility, location, etc. How do I get the called vba to recognize it?
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-27-2010
    Location
    Adelaide
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Using a call procedure

    Hi narrow,
    in your code for form frmAccruedPTO, when you call the procedure 'accrued_pto_reg' you need to pass the data as variables.
    i.e. change the line to:
    Call accrued_pto_reg strFac, strLoc etc etc

    Then in the procuedure, change the sub to:
    Public Sub accrued_pto_reg(strFac, strLoc etc etc)

    Hope that helps.
    Skimmer333

  3. #3
    Registered User
    Join Date
    09-27-2010
    Location
    Adelaide
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Using a call procedure

    To expand (i'm shocking at explaining)

    Add these to the section just above your call area.
    strFacility = Facility
    strLocation = Location
    strCycle = Cycle
    strKronos = Kronos
    strEffective = Effective

    Then change your calls to:
    call accrued_pto_reg(strFacility, strLocation, strCycle, strKronos, strEffective)

    Then change your procudure to:
    Public Sub accrued_pto_reg(strFacility, strLocation, strCycle, strKronos, strEffective)

  4. #4
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    237

    Re: Using a call procedure

    Interesting. I couldn't quite figure out the first response, but had left before you posted the followup. I ended up just putting (Facility, Location, Cycle, Kronos, Effective) in both places. Then I commented out the Dim statements on the procedure. It seemed to work, but now that I see your explanation, I wonder if mine is not working like I thought. What do I lose by not putting in all the str's?

+ 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