Filter based on control on a tab page

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Filter based on control on a tab page

Post by Leesha »

Hi,

I know I've asked this before but can't find the answer. I need to refer to a textbox that is on tab page control to filter a query. I have [forms]![frmReports]![pageorders]![txtOrderFilter] but its not working. If I put the textbox outside the tab control and take out the reference to [pageorders]it works fine. How do I use it while on the tab page?
Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Filter based on control on a tab page

Post by HansV »

There is no need to include the tab control in the reference. Whether the text box is on a tab page or not, you should be able to use

[Forms]![frmReports]![txtOrderFilter]
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Nope, not working. If I take the conrol off the tab page which is in the details section of frmReports and put it on the form header it works fine. The minute I put it on the tab page it doesn't return the results.

Leesha

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Filter based on control on a tab page

Post by HansV »

Are you sure that you don't place the control in a subform?
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

There is no subform, just the tab control. I'm more confused than ever becasue I went to strip down the database to send it to you it ran. So I logged back on to try it again and it ran. I didn't make any changes. The only difference is I'm using remote desktop from home vs from an office site. I guess I'll have to blame this on the phone lines!

Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Filter based on control on a tab page

Post by HansV »

Well, at least it works now!
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Thank God! Now, if I did have a subform on a tab control (which is what I'm trying now) how would I refer to that in query or is it possible?

Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Filter based on control on a tab page

Post by HansV »

You'd use

[Forms]![frmReports]![sbfSubform]![txtOrderFilter]

where sbfSubform is the name of the subform as a control on the main form frmReports. This is not necessarily the same as the name of the subform in the database window. To find the control name, open the main form in design view and click once on the subform to select it. The control name will be listed in the Properties window.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Worked like a charm! Thanks for the tip on the name. That was a big help.

Leesha

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Back Again! Same tab page. Now it has a textbox conrol [txtARPassword]. The user enters the password and the code looks to see if its correct before opening the report. This works fine if the control is on the form header but the minute I put it on tab page I get an error that it can't be found. If I I start typing the codes with me. it doesn't come up in the list. I tried forms!frmReports!txtARPassword and get an error that states that frmRports can't be found. The control isn't on a subform.

Thanks!
Leesha

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Filter based on control on a tab page

Post by Wendell »

That starts to sound like you may have a form corruption problem. Can you use the properties box to select the txtARPassword control? If not, then the form is suspect. Also, can you refer to the control in VBA using Me.
Wendell
You can't see the view if you don't climb the mountain!

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

I was able to see it in the properties and confirmed that the name was correct. I had tried the VBA using me but it didn't populate. Since ou mentioned that the form might have an issue, I did a compact and repair of the database and when I reopenned it I was able to find the control.

Thanks!
Leesha

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Filter based on control on a tab page

Post by Wendell »

I did a search but couldn't identify what version of Access you normally use. I've recently been working on stuff for a client still on 2002 (current with SP3), and have had a spate of problems with forms going corrupt when I try to save them. Not much fun!
Wendell
You can't see the view if you don't climb the mountain!

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

That's the version I'm using too. And yes, its frustrating as all get out. I think the "compact and repair" button is going to be my new best friend!

Leesha

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Filter based on control on a tab page

Post by Wendell »

If that's the case, and you've been developing for some time in that database, you may want to pull everthing into a new database - that tends to clear some of the cobwebs in Access up. Another option is to save the entire database to text and then rebuild it from text. That's more laborious, but it does resolve the issues with forms being edited some much that they have to be rebuilt. Unfortunately neither of those is really an option, as the database I'm working on has a bunch of addins installed, and I have to jump through lots of hoops to do that. In addition, the client will move to 2007 (or 2010) in a matter of weeks and then I know I will have to rebuild it.... :hairout: and there's not much left any more...
Wendell
You can't see the view if you don't climb the mountain!

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Oh dear God I feel for you! What do you mean by "there's not much left anymore"?

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Filter based on control on a tab page

Post by Wendell »

If you check out my photo on the other Lounge, or on FaceBook, you'll see what I mean...
Wendell
You can't see the view if you don't climb the mountain!

Leesha
BronzeLounger
Posts: 1484
Joined: 05 Feb 2010, 22:25

Re: Filter based on control on a tab page

Post by Leesha »

Ahhhh!! Got it! :laugh:

Leesha