Using value from Input Box in another function

goaksmith

Registered User.
Local time
Yesterday, 18:39
Joined
Jul 31, 2002
Messages
74
I apologize if this has been posted already. I have looked at several examples of coding that people have posted but I cannot figure out my problem. I am sure it is a simple problem for someone who has more coding knowledge than I do. I have a function which prompts you for a fund number. This is working fine.

********************************
Function StrDSTFundNumber()
Dim DSTFundNumber As Long

DSTFundNumber = InputBox("Enter DST Number", "DST Number")

End Function
********************************
Now my problem is that I have another function that performs several different tasks. Here is the beginning of the code.

********************************
Function UpdateBlueSkyFund(paramDSTFundNumber As Long)
Const ALL_BUT_THRESHOLD = 25

Dim strOpenStatesBuffer As String
Dim strClosedStatesBuffer As String
Dim lngOpenStates As Integer
Dim lngClosedStates As Integer
Dim recBlueSky As Recordset
Dim lngStateCounter As Integer
Dim recStateCodes As Recordset
Dim strStateCode As String
Dim lngFields As Integer
Dim strFinalPhrase As String
Dim strForeignBuffer As String
Dim lngDSTFundNumber As Long
Dim db As Database

' Trap blank DSTFundNumber parameter
If IsNull(paramDSTFundNumber) Or paramDSTFundNumber = 0 Or paramDSTFundNumber < 0 Then Exit Sub
lngDSTFundNumber = paramDSTFundNumber

' Setup Variables
strOpenStatesBuffer = ""
strClosedStatesBuffer = ""
strForeignBuffer = ""
lngOpenStates = 0
lngClosedStates = 0
lngStateCounter = 0

*****************************

Now my problem is that I need to get the DSTFundNumber from the first function to be the value used in the 2nd function. I have the two functions individually, but I cannot figure out how to put them together. The DSTFundNumber in the first function is the (paramDSTFundNumber) in the second function.

I hope this makes sense. Any help would be appreciated. Thanks in advance!
 
Your code should work, it just requires a 3rd procedure or function to call the first function, then pass the result to the 2nd function.

Why don't you rewrite the StrDSTFundNumber() function as:

Function StrDSTFundNumber()
strDSTFundNumber= InputBox("Enter DST Number", "DST Number")
End Function

just to simplify it.

You can call it directly from the 2nd function like:
paramDSTFundNumber=StrDSTFundNumber()
just before the line that says:
' Trap blank DSTFundNumber parameter
 
Thanks! This did exactly what I wanted it to do.
 

Users who are viewing this thread

Back
Top Bottom