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!

Is it possible to display two forms on the same form?? 1

Status
Not open for further replies.

greg32246

Technical User
May 21, 2009
19
US
I am not talking about a parent/child relationship. What I have is two seperate forms,each with data that is unrelated. I am trying to present the user with the data from both forms on one screen. I thought I could just take an unbound form and add each form to it. But, I can only add the forms as subforms and Access is expecting some kind of relationship.

Is it not possible to do what I want, or I am just missing something.

I don't want my users to have to tile seperate windows and I need them to be forms capable of data input.

Any help would be appreciated.

Thanks
 
After further testing the problem I am having has to do with the filters applied to the individual forms. I can display the two forms fine without filters. But, if I click on the apply filter, only one of the forms filters properly.

 
Which (probably) means, you will have to apply filters in VBA code. How about putting your subforms in the detail section and a command button in the header or footer. Code the click event to apply filters to both subforms.


Randy
 
Here is a possible solution (or part of one)

Assume I have two sub form controls on an unbound main form:
subFormCtlOne and subFormCtlTwo

containing the subforms
subFrmA and subFrmB

In subFrmA I put this code

Code:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
  Dim frmName1 As String
  Dim frmName2 As String
  Dim fltr As String
  
  frmName1 = Me.Name
  frmName2 = Me.Parent.subFormCtlTwo.Form.Name
  fltr = Me.Filter
  Debug.Print fltr
  fltr = Replace(fltr, frmName1, frmName2)
  Debug.Print fltr
  Me.Parent.subFormCtlTwo.Form.Filter = fltr
  Me.Parent.subFormCtlTwo.Form.FilterOn = True
End Sub

Here is why you need the replace code. The subform's name is put in as part of the filter string so before the replace
(([subFrmA].[ID]>=1)) AND ([subFrmA].[ID]<>1 Or [subFrmA].[ID] IS Null)
after the replace
(([subFrmB].[ID]>=1)) AND ([subFrmB].[ID]<>1 Or [subFrmB].[ID] IS Null)

Now if I use the filter by selection on subFrmA it filters subfrmB as well.

You could put the same code in subfrmb so if you filter subfrmb it would apply that filter to subFrmA
 
Thanks guys for the responses.

I went down the route that Randy700 suggested. I was already trying to set the Filters via VBA code, but I was doing so on the Open Event of each subform with a generic Docmd.Applyfilter line of code. That didn't work!

I still wanted the filters to be applied when the main unbound form opened, so I moved the code to the Open Event of the main unbound form. There I just used the Filter and FilterOn properties and applied them explicitly to each subform.

That worked. I didn't have to move the subforms to the detail section of the unbound form.

I was also able to update the forms using the Requery method using the same technique.

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top