Use form values in another form

T
he error I get now is Run-time error '94': Invalid use of Null, in line Me.textbox5= (cdbl(split(openargs,":")(0)))
could also be that there is no value in form1, textbox1
 
could also be that there is no value in form1, textbox1
Untested, but I think this will hopefully solve that case
Code:
if isnumeric(split(me.openargs,":")(0)) then me.textbox5= (cdbl(split(openargs,":")(0))) ' check you passed a number
if isnumeric(split(me.openargs,":")(1)) then Me.textbox6 =(cdbl(split(openargs,":")(1)))
 
cross posted

adjudante please read https://www.excelguru.ca/content.php?184
 
bit cheeky, not even acknowledging it is not their own work - so I'm outta here, let the other forum take it up
 
bit cheeky, not even acknowledging it is not their own work - so I'm outta here, let the other forum take it up

This is why I have a larger ignore list than (probably) most. If the OP acknowledges the transgression, then NP. If not, another one's on the list. I figure that I have better things to do than spend my time on those who don't care or don't understand.
 
before anything, edit Form2 and add a Public function:
Code:
Public Function get_global(byval idx as integer) as single
get_global = 0
if idx = 1 then
    get_global = gbl_var1
elseif idx = 2
    get_global = gbl_var2
end if
end function

set the ControlSource of Textbox5 (form2) to:
Code:
=get_global(1)
likewise with textbox6 (form2):
Code:
=get_global(2)

1. in Module1 (module):
Code:
Global gbl_var1 as single
Global gbl_var2 as single
2. in form1 (click event of a button to open form2)
Code:
private sub button1_click()

gbl_var1 = val(me.textbox1 & "")
gbl_var2 = val(me.textbox2 & "")

if syscmd(acSysCmdGetObjectState, acForm, "Form2") > 0 Then
    docmd.close acForm, "Form2"
end if
docmd.openform "Form2"

docmd.close acForm, me.name
 

Users who are viewing this thread

Back
Top Bottom