Click to See Complete Forum and Search --> : from one form to the other form


ariel_au
March 31st, 2001, 09:08 AM
i have 2 forms named "frmMain" and "frmCustom".

'in frmMain
option Explicit
' Global variables hold the total number of columns and rows
private TotalCols as Integer
private TotalRows as Integer
private Sub Form_Load()

TotalCols = frmCustomField.CWidth
TotalRows = frmCustomField.CHeight
End Sub
--------------------------------------------------------------
' in frmCustom
option Explicit
private Sub cmdOk_Click()
Dim CHeight as Integer, CWidth as Integer
CHeight = Val(txtHeight.Text)
CWidth = Val(txtWidth.Text)
End Sub




well, the above is part of my project and i have a problem with that.
in frmCustom, i have 2 textboxes named "txtHeight" and "txtWidth" and i want to pass the values in "txtHeight" and "txtWidth" to frmMain. how can i get that?

shree
March 31st, 2001, 09:26 AM
Declare the variables as Public in frmMain. Then you can access the variables from frmCustom as
FormName.VarName

I have modified your code to do the same.


'in frmMain
option Explicit
' Global variables hold the total number of columns and rows
public TotalCols as Integer
public TotalRows as Integer
private Sub Form_Load()

TotalCols = frmCustomField.CWidth
TotalRows = frmCustomField.CHeight
End Sub
--------------------------------------------------------------
' in frmCustom
option Explicit
private Sub cmdOk_Click()
Dim CHeight as Integer, CWidth as Integer
CHeight = Val(txtHeight.Text)
CWidth = Val(txtWidth.Text)
frmMain.TotalCols = CWidth
frmMain.TotalRows = CHeight
End Sub

ariel_au
March 31st, 2001, 09:43 AM
its still does not work..

CCDriver
March 31st, 2001, 05:35 PM
I had a similar problem just a little while ago, i wanted textbox's on the second form to display in the first form after clicking the ok button in the second form.
( i was going from the second form to the first, sounds like your just calling the second form )

What i had to do was call the name of the first form like this "fMainForm."
You are doing it differently so i don't know if that will help you but i think you have to name the form in full to get values from it (like a path statement).

ariel_au
March 31st, 2001, 06:20 PM
can u show me ur code so that i can try and figure it out...

CCDriver
April 1st, 2001, 06:50 AM
I dont have it on this computer, but see if this helps.
Change:
frmMain.TotalCols = CWidth
frmMain.TotalRows = CHeight

To:
fMainForm.TotalCols = CWidth
fMainForm.TotalRows = CHeight

See if that works in the mean time.
Did you start this project from the wizard? because if you did look in the module (top), there should be something in there that the wizard put in about nameing the form fMainForm, thats what had me stumped for a while.