Passing Variable Value

D

DEI

I have very little experience passing variables between forms, modules, etc.
I haev experimented with creating public variables in a forms declaration,
but have not had any luck.

I would simply like to populate a field on an open form with a value after a
record in another form is created, but I only want this to happen in specific
scenarios. So I want to pass a boolean variable from one sub to another on
another form, create an if statement, etc., but I do not know how to do this.

Where/how do I declare the variable?

Thanks in advance.

DEI
 
T

Tom van Stiphout

On Tue, 2 Dec 2008 15:33:02 -0800, DEI <[email protected]>
wrote:

You say: "after a record in another form is created". That means the
Form_AfterUpdate event in the OtherForm. So in that event write:
Forms!myFirstForm!myControl.Value = someValue
(of course you substitute your form, control and variable names)

If you want to do this conditionally then:
if someValue = True then
Forms!myFirstForm!myControl.Value = someValue
end if

or:
if someComplicatedChecking() = True then
Forms!myFirstForm!myControl.Value = someValue
end if

private function someComplicateChecking() as Boolean
'do your thing
someComplicateChecking = True 'or False :)
end function

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top