Pass Variables into Form's code
How do I pass a variable from a standard module into
the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
Pass Variables into Form's code
Stuart,
Declare it as a public variable in the Declarations section of a normal code module, and it will be available to the userform. -- HTH Bob Phillips "Stuart" wrote in message ... How do I pass a variable from a standard module into the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
Pass Variables into Form's code
Hi Stuart,
There are several approaches. One is to define a property in the Form. Something like: Dim m_HideSameCols As Boolean Public Property Set HideSameCols(byval a_bHideAs Boolean) m_HideSameCols = a_bHide End Property Then from your caller you would use: Load GetUserWkbk_PrintOptions GetUserWkbk_PrintOptions.HideSameCols = Global_HideSameCols GetUserWkbk_PrintOptions.Show Alternatively if you define Global_HideSameCols in a code module as: Global Global_HideSameCols As Boolean it will also be visible in your form. I would generally use the second method, because it involves less typing (and also because your variable name says it global <g), although the good design mafia (who deprecate global variables) would no doubt advocate the first. HTH Peter Beach "Stuart" wrote in message ... How do I pass a variable from a standard module into the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
All times are GMT +1. The time now is 02:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com