Access 2013 - open same tabbed form multiple times

In tabbed view, is it possible to open a form with certain filters, then open it again in another tab, with a different filter?
rick_dangerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Yes, at OnOpen set the value (the page index) of the tab control:

    Dim PageIndex As Integer

    PageIndex = 1  ' 0 to Count of Pages - 1

    Me!MyTabControl.Value = PageIndex

If you mean "open a subform", then make a copy of this on another page of the tab control. They will work independantly.

/gustav
0
rick_dangerAuthor Commented:
Gustav
Thanks.
No, I don't mean subform. What do I put for "MyTabControl" please?
0
Gustav BrockCIOCommented:
MyTabControl is the name of your tab control.

/gustav
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rick_dangerAuthor Commented:
Where do I find that?
0
Gustav BrockCIOCommented:
Oh, it's tabbed view. Missed that.

Then you will open another instance of the form:

    Dim TheOtherFormInstance As Form

    DoCmd.OpenForm "frmYourForm"

    Set TheOtherFormInstance = New Forms!frmYourForm

/gustav
0
Gustav BrockCIOCommented:
Sorry, it takes a little more:
Public Sub SecondForm()
    Dim frm As Form
    Dim frm2 As Form
    
    Set frm = Forms!frmYourForm
    Set frm2 = New Form_frmYourForm
    frm2.Visible = True
    
    ' Do stuff with frm2
    Stop
    ' frm2 will close when you exit the function.
    
End Sub

Open in new window

/gustav
0
rick_dangerAuthor Commented:
Gustav
Thanks, but where do I run this code from please?
0
Gustav BrockCIOCommented:
That could be from where you now open the first form. Use a similar function instead.

It will open the first instance, then move on and open the second. One method to keep the second open, is to open it as modal. Then the code stops before the Stop line (which you, of course, will remove, it's for demo only) and waits until the user closes the second instance.

/gustav
0
Dale FyeCommented:
If the reason for doing this is to compare data with the different filters, then keeping track of which form is open and closing them properly, in the order you want, can be challenging.  You might want to consider simply creating a 2nd form identical to the first, but with a different name.
0
rick_dangerAuthor Commented:
No, it's just that I have a report, "rpt_list_horses" which is actually a list of horses and if you click on a horse, you get his past form on a different report, "rpt_linked_runners", filtered by horse name. But you may wish to look at another horse by clicking on his name on the same report report, "rpt_linked_runners". So this would open that same report, "rpt_linked_runners", but filtered by the other horse name.

Sorry, in my original question I mentioned forms, but I should have said reports.
0
Gustav BrockCIOCommented:
I haven't tested, but it should work for reports as well.

/gustav
0
rick_dangerAuthor Commented:
I'm still not understanding this method. The first report is the same as the second, and potentially, 3rd, 4th, 5th, etc. So I would link to this code on the Open Event of the report?
0
Gustav BrockCIOCommented:
Well, as you wish. But you mentioned ".. you may wish to look at another horse by clicking on his name on the same report". If so:

    Set rpt2 = New Report_rptYourReport
    rpt2.Filter = "ID = " & Me!ID.Value & ""
    rpt2.Visible = True
    Stop    ' for demo only

/gustav
0
rick_dangerAuthor Commented:
This isn't making a great deal of sense to me. I'm sure it's my fault, not yours. However, I clearly need more explicit answers for me to be able to get where I want to get to. Where do I put this code please?

Also, you mention rpt2, which implies, maybe mistakenly, that you have hard-coded that this opens the 2nd instance of that report. If so, can this solution cope with a 3rd or 4th instance?
0
Gustav BrockCIOCommented:
This would be the OnClick event of the control where the user does ".. clicking on his name on the same report".

And yes, you can open as many as you wish. However, as soon as the report object vanishes, that report is closed. This means that if you wish to have multiple reports open, you must create something that keeps the object(s) open, for example by adding them to a Collection. This method is described here:

http://allenbrowne.com/ser-35.html

It also explains how to get hold on these by use of the hWnd property as they will be named the same.

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rick_dangerAuthor Commented:
OK, thanks.

I will need to spend time on this to test it out properly, but you have, at the very least, pointed me in the right direction on this so I am happy to award you the points.

Thanks for your time.
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
Dale FyeCommented:
Gustav,

I've never tried this with a report before, but see attached.  What I found was that if the report was not already present in the Reports collection, instantiating a new report with

set rpt = New Report_Report1

did not work.  So I created a loop to test whether that report was already in the collection, and it now works.  The down side of this method is that since the default view for the report is ReportView, the 2nd version of the report opens in ReportView rather than PrintPreview. Are you familiar with any way to work around this?

 It also was not extensible to 3rd or 4th reports.  I think you would need to create a Collection and assign these reports to the collection in order to extend it beyond 2 reports.
MultiReport.accdb
0
Dale FyeCommented:
Oops, I see Gustav has already addressed most of this, except the issue about the default ReportView rather than PreviewView.
0
Gustav BrockCIOCommented:
No, I haven't played with it, but your observations seem right.

If you set and save the report with DefaultView set to PrintPreview, both instances will open this way.

I believe the Collection method is the simplest to hold the instances open.

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.