The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Passing parameters to a form
Posted: 06 Oct 08 7:54 AM
|
I'm coding some simple scripts that all need to call the same form but with different parameter values; however, I'm unclear as to how to pass those parameters to the form.
Thanks, Sam in Northern Carolina
|
|
|
|
Re: Passing parameters to a form
Posted: 06 Oct 08 1:23 PM
|
Hi Sam,
Use Globals:
Application.GlobalInfo("MyParameter1") = MyValue1 Application.GlobalInfo("MyParameter2") = MyValue2
Globals are really useful as they will hold and Variant - including objects.
Stephen www.slxmaster.com
|
|
|
|
Re: Passing parameters to a form
Posted: 06 Oct 08 4:08 PM
|
Great idea. I'm trying this approach but the form isn't recognizing the global variable it appears. Here is the calling script:
option explicit
Dim myParm
sub Main() InvokeMonthlyRptMenu end sub
Sub InvokeMonthlyRptMenu()
application.GlobalInfo("myParm") = "Wide" msgbox " set global parameter = " & application.GlobalInfo("myParm")
application.GlobalInfo.Item ("CallingForm") = application.GlobalInfo.Item ("strCurrentForm") application.GlobalInfo.Item ("strCurrentForm") = "General" application.BasicFunctions.DoInvoke "view","personal:Monthly Report Filter View" end Sub
I must be missing something obvious....
|
|
|
|
Re: Passing parameters to a form
Posted: 06 Oct 08 4:49 PM
|
Are you saying that the bit:
Application.GlobalInfo("MyParm") = "Wide" MsgBox "Value set: " & Application.GlobalInfo("MyParm")
Is not working? Because that works fine for me (and always has).
I note that you are setting the Global for "strCurrentForm" after you are assigning the value "CallingForm" - is this an error?
What is the code in the Monthly Report Filter View that picks up the Global - what event are you using? OnOpen, OnChange? Remember that OnChange will not fire if there are no bound fields on the form.
Stephen www.slxmaster.com
|
|
|
|
Re: Passing parameters to a form
Posted: 06 Oct 08 8:00 PM
|
Rather than using globals, you have the option of using a main view to display your form and passing stuff to that directly in your code - here's some hacked code from Add Opportunity Product to give you an idea:
Dim objMainView, objDetail
Set objMainView = Application.MainViews.Add("System:Update Opportunity Currency", 0, False) 'DNL objMainView.BorderStyle = 3 objMainView.Caption = Application.Translator.Localize("Update Opportunity Currency") Set objDetail = objMainView.DetailsView if GetMCSystemInfoValue(MC_ChangeOppExchangeRate) = "T" then objDetail.txtExchangeRate.Enabled = True Else objDetail.txtExchangeRate.Enabled = False End if If GetMCSystemInfoValue(MC_LockOppRate) = "T" then objDetail.chkLock.Enabled = True Else objDetail.chkLock.Enabled = False End if objDetail.lblCurrencyType.Caption = txtCurrency.Text objDetail.txtPotentialFrom.Text = FormatPrice(FormatNumber(txtExtendedPriceTotal.Text, 2), GetMCValue(MC_On)) objDetail.lblFromType.Caption = objDetail.lblCurrencyType.Caption objDetail.Script.Init objDetail.txtHiddenSalesPotential.text = txtExtendedPricetotal.Text/ppeExchangeRate.Text objDetail.lblToType.Caption = txtCurrency.Text objDetail.txtPotentialTo.Text = ppeExchangeRate.Text objDetail.lveChangeTo.Text = txtCurrency.Text objDetail.txtExchangeRate.Text = ppeExchangeRate.Text 'Need this global to track the ExchangeRate if the user cancels on the Update Opp Currency view AFTER manually changing the value. Application.BasicFunctions.GlobalInfoSet "UpdateOppCurrency", objDetail.txtExchangeRate.Text 'DNL
If objMainView.ShowModal = mrOK Then txtCurrency.Text = objDetail.lveChangeTo.Text ppeExchangeRate.Text = objDetail.txtExchangeRate.Text Else
etc etc.
Various values on the form "System:Update Opportunity Currency" are set in code before the form is displayed (objMainView.ShowModal displays it to the user as a modal form).
While this may seem more complicated than using globals, you do have more control and the end solution is tidier (IMO).
Phil |
|
|
|
Re: Passing parameters to a form
Posted: 07 Oct 08 12:22 PM
|
The MsgBox code in the calling script is exhibiting the value correctly. In the called form, I'm trying to use the global variable in the OnOpen event. A similar MsgBox in the form's OnOpen code exhibits no value. |
|
|
|
Re: Passing parameters to a form
Posted: 07 Oct 08 12:29 PM
|
Did you swap the order of the two lines like I suggested?
From:
application.GlobalInfo.Item ("CallingForm") = application.GlobalInfo.Item ("strCurrentForm") application.GlobalInfo.Item ("strCurrentForm") = "General"
to
application.GlobalInfo.Item ("strCurrentForm") = "General" application.GlobalInfo.Item ("CallingForm") = application.GlobalInfo.Item ("strCurrentForm")
My experience suggests that if this is not working then you are doing something wrong. Sorry.
Stephen
|
|
|
|
Re: Passing parameters to a form
Posted: 07 Oct 08 12:33 PM
|
Stephen, thanks for the quick reply. I tried the code change as well to no avail. I'll look at the other option suggested. Thanks again. |
|
|
|