Click to See Complete Forum and Search --> : working with 2 forms in a project


ariel_au
March 28th, 2001, 07:04 AM
i created 2 forms in a project. one form called frmMain and other is frmCustom.
form frmCustom have the textbox input for "height" and "width".how do i get the values from "height" and "width" in frmCustom to the other form "frmMain"?

Clearcode
March 28th, 2001, 07:16 AM
You can refer to any control of any loaded form by name thus:

public Sub CommandResize_Click()

me.Width = frmCustom.txtWidth.Text

End Sub




HTH,
Duncan


-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

Cubbie
March 28th, 2001, 07:45 AM
If I'm reading this correctly you are entering values in a textbox on one form and want to get those values to another form? You can either reference the first form frmMain.text1.text = frmCustom.text1.text or create a global variable in a module to capture the values on frmCustom and transfer them to frmMain as below:

In code module:

Public strHeight as String
Public strWidth as String

In frmCustom after entering value:

strHeight = text1.text
strWidth = text2.text

In frmMain:

text1.text = strHeight
text2.text = strWidth

ariel_au
March 28th, 2001, 09:12 AM
hi,
thanks. by the way, you wrote:
In code module:
Public strHeight as String
Public strWidth as String

is it writting the above in the "standard module" .bas?

Cubbie
March 28th, 2001, 09:21 AM
Yes. Put the variable declations in a bas module.

ariel_au
March 28th, 2001, 10:00 AM
what is a bas module? i mean when should i use bas module and when i should i not use it?

Cubbie
March 28th, 2001, 03:23 PM
Use a BAS module to declare ojects globally for use anywhere in your application. Just select Project|Add Module and save it as a .bas file.