Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass parameters

Status
Not open for further replies.

jodie

MIS
May 18, 2001
30
US
I am having a problem passing parameters..
I am trying to pass the parameter boolPlans which contains a 0 or 1 value to another procedure in another form.

However, when I run this, I get the error:
Microsoft VBScript Runtime error: Wrong number of arguments or invalid property assignment: ConsolidateCompany
------------------------------------------------------------
MY CODE
------------------------------------------------------------

Sub HasRSPlans()

Dim boolPlans '(to see whether plan is attached or not)

With rstPrimaryRecordset
If UIMaster.RUICenter.GetRecordset(strsRSPlan).RecordCount > 0 then
Global.CMSMsgBox "Has RS Plans attached", vbOKOnly,"Warning"
boolPlans = 1
ConsolidateCompany(boolPlans)
Else
Global.CMSMsgBox "No RS Plans attached", vbOKOnly,"Warning"
boolPlans = 0
ConsolidateCompany(boolPlans)
end if
End With
End Sub

---------------------------------------------------------
(2.)
Sub ConsolidateCompany(boolPlans)
MsgBox "If Plans attached is 1 and if not is 0: ..." & boolPlans
End Sub

Can someone please help me out urgently. I desperately need help as I don't know what is wrong..
 
when you pass parameter to user defined procedures you should use functions.
so just change to
Function ConsolidateCompany(boolPlans)
MsgBox "If Plans attached is 1 and if not is 0: ..." & boolPlans
End Function

also the msgbox fucntion should be declared to a variable
eg:
Dim MyMsg
MyMsg = MsgBox "If Plans attached is 1 and if not is 0: ..." & boolPlans

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
It doesn't seem to help.
I still get the same error.
 
To pass a var. to a sub call the sub and put the var. name after the sub placing an comma between each variable you want to pass.

subcall var1,var2,var3


sub subcall(var1,var2,var3)
code
end sub
 
Or:

<%

'Call sub in page.
call HasRSPlans(boolPlans)

%>

<%

Sub HasRSPlans(boolPlans)

-- some code

end sub
%>

And get rid of this line within the sub:

Dim boolPlans '(to see whether plan is attached or not)

Since you are passing in the value, you don't want to declare it locally. In fact, I don't think that you can.

Mark

 
Try this:
Code:
Sub ConsolidateCompany(boolPlans)
MsgBox &quot;If Plans attached is 1 and if not is 0: ...&quot; & boolPlans
End Sub
Sub HasRSPlans()
Dim boolPlans, strMsg
If UIMaster.RUICenter.GetRecordset(strsRSPlan).RecordCount>0 Then
  strMsg=&quot;Has RS Plans attached&quot;
  boolPlans=1
Else
  strMsg=&quot;No RS Plans attached&quot;
  boolPlans = 0
End If
Global.CMSMsgBox strMsg,vbOKOnly,&quot;Warning&quot;
ConsolidateCompany boolPlans
End Sub

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top