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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access background form from front form

Status
Not open for further replies.

kshea

Technical User
May 31, 2002
60
CA
Hi All:

I have two forms. One is main form with a listview and button to open the subform; another one is subform with a listview as well. The subform is modeless. The subform is open and main form is in background. I need to store the item in the subform to the main form. In the subform, I called the main form like this:

frmMain. AddSubFormItemToMainForm

So I can update the items in two forms simultaneously.

The problem is if I run the procedure above, it will bring up the main form to the front. Even the subform sets to Model, I still see the main form flashing in the front.

I tried to keep a global list to add the subform items to main form when unload the subform in order to avoid access the main form inside subform. But it won’t allow me update the list simultaneously, that is, subform has to be closed.

Anyone has a better solution for it? Thank you in advance.
 
Here are a couple of ideas.

Have you tried making the main form an MDIForm and the sub form an MDIChild?

Have you tried putting the routine AddSubFormItemToMainForm inside of the sub form?

The two forms can communicate using Property Let and Property Get statements. Create modular variable in the main form for the items that you will add.

i.e.
in frmMain:

Private m_sItem as String
Property Let Item(sVal as String)
m_sItem = sVal
End Property

in frmSub:
Private Sub AddSubFormItemToMainForm
frmMain.Item = "ITEMTOADD"
End Sub

When you release the sub form, you can run a routine (maybe in your Activate Event) for the main form to add the item.

in frmMain:
Private Sub Form_Activate
txtItem = m_sItem
End Sub

I'm not sure if that's what you were getting at, but hopefully I've given you some ideas that might be of some help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top