Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

values between forms question

Status
Not open for further replies.

eulogy6

Programmer
Apr 30, 2004
26
Hello to all,
I have a main form with a datagrid,
frmImportsForm & frmAnalysisDetails
How I Know which form is open (frmImportsForm OR frmAnalysisDetails), in order to pass a value?

I suppose my question is very simple.

Private Sub DataGrid1_DblClick()
If frmImportsForm.Hide = True (something like that) Then
frmAnalysisDetails.Text11.Text = Me.Text1.Text
else
frmImportsForm.Text6.Text = Me.Text1.Text
End If
Unload Me
End Sub
 
I suppose if the forms are already loaded but merely hidden you could check the .Visible property.
 
Sheco thanx for your replay

Lets say, I have already frmAnalysisDetails loaded.
If i use the .visible property the "If" statment dosen't work what fires both forms

Any other idea?

Thanx in advanced
 
Set the .Tag property when a form is open, and change it when it closes.

Code:
Form1.Tag=1 ' Open
If Form1.Tag=1 then msgbox "Form 1 Open"

-David
2006 Microsoft Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
thanx four your help...

The .Tag property is a good idea, but how can I use the
"If statment"?

Something like that

Private Sub DataGrid1_DblClick()
If frmImportsForm.Tag = 1 Then
frmAnalysisDetails.Text11.Text = Me.Text1.Text
else
frmImportsForm.Text6.Text = Me.Text1.Text
End If
Unload Me
End Sub
 
I'd really think again about this one...

I suspect that each time you try and reference one of the forms properties, you are (re)creating an instance of it.

Personally I suggest you try something like
Code:
Dim fAnalysis as frmAnalysisDetails
dim fImports as frmImportsForm

Set fAnalysis = new frmAnalysisDetails 'explicit instancing
set fImports = new frmImportsForm 'explicit instancing, but don't create object until you need it

'Soem code

'finished with object
Set fImports = nothing

Then if you want to test whether form is loaded
Code:
if fImports is nothing then
' It isn't instanced
else
' it is instanced
end if

At the moment, everytime you use a form property, if the form doesn't exist the form will be created

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I would just hide them rather than unloading them, so that the tag wouldn't load them again.

-David
2006 Microsoft Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top