Best way to pass data between forms?

  • Thread starter Thread starter fedude
  • Start date Start date
F

fedude

I have a form (form A) that "shows" another form (form B). Form B collects
data that I want to be available to Form A when Form B is unloaded.

In addition I want to pass data from Form A to Form B when it is
instantiated. I assume I can set the value of hidden label when I create
form B, but this seems a little stupid.

Any advice on how to do this?
 
Declare a public variable in a standard code module, simplest way.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I have a form (form A) that "shows" another form (form B).  Form B collects
data that I want to be available to Form A when Form B is unloaded.

In addition I want to pass data from Form A to Form B when it is
instantiated.  I assume I can set the value of hidden label when I create
form B, but this seems a little stupid.  

Any advice on how to do this?

I agree with Bob. Declare Public variables in a standard module and
then set them as needed. For instance, if you want textbox1 on Form B
to be populated when it opens with the value from textbox2 on Form A,
you could use:

Standard module:
Public example As String

Button on Form A that opens form B
example = Me.textbox2

Initialize event of Form B
Me.textbox1.Text = example

HTH
 
Do I just creat another module anyhere in the spreadsheet or is there
someplace special I need to declare these variables?
 
Do I just creat another module anyhere in the spreadsheet or is there
someplace special I need to declare these variables?










- Show quoted text -

They just need to be declared at the top of a standard module. I
typically create a module for nothing but my public declerations.
 

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

Back
Top