PDA

View Full Version : Pass a Variable in a Form to a new form



cjmitton
01-23-2014, 08:16 AM
I'm having trouble passing a variable from one form to another. I have a file path as a string declared in one form. Example: \\servers\share1\share2 I've tried to then pass the variable to the other form using FillVars like follows:
' this code runs when checkbox is trueSub get_std_letts() Dim SF As String ' Startfolder is declared in a different macro but is available to this macro as its a public variable SF = StartFolder Load frm_Clt_Letters Call frm_Clt_Letters.FillVars(SF) frm_Clt_Letters.Showend sub'On the other formSub FillVars(ByRef s1 As String)StartFolder1 = s1End Sub' Startfolder1 is public declared as a string and used in the form Inilialize macro.I've used this way of passing on a variable before and its been fine but this is not working now?

cjmitton
01-23-2014, 08:18 AM
Sorry about the format, won't recognise my carriage returns?

westconn1
01-23-2014, 01:38 PM
use a public module level variable
otherwise pass the string to some property of form2 before opening

cjmitton
01-23-2014, 02:36 PM
Damn, should have thought of that! Get so blind to the obvious solution when I'm focused on the problem.

Thanks Westconn1