Selasa, 12 Juli 2011

[MS_AccessPros] Re: Access 2003: subform on tab control - how to set recordsource programmatically

 

Sandra

You won't be able to use the same sub form on all tabs unless you open separate instances. That in itself is fraught with things that can go wrong.

I suggest you just make 4 subs, one for each tab. That way they are all set up as to how to filter.

Using the tab control's Change event would let you set the rowsource for the sub form on the selected tab.

Here is what I did:
I set the subform's RecordSource to a query on its table where Tag_Type = 10. Since the sub is linked to the text box in its main, it will automatically show only the 10's.
SELECT TBL_Tag.Tag_QueryName
, TBL_Tag.Tag_Type
, TBL_Tag.Tag_Literal
, TBL_Tag.Tag_AutoNum
FROM TBL_Tag
WHERE TBL_Tag.Tag_Type=10;

Do the same for each tab. Put a new sub with the proper query

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile/Bill.Mosca

--- In MS_Access_Professionals@yahoogroups.com, "happily613b" <mytfein@...> wrote:
>
> Hi Everyone,
>
> Hope all is well.... it's been a while since i posted a question.......
>
> I would like to programmatically set the record source of a subform on a tab....
>
> I am very new to tabbed form and referring to controls on a tab.
>
>
> some background info:
> ===================
>
> a)i want the user to assign "tags" to queries to create a kind of index for which to search by tag for queries.
>
> (Please be aware that these queries are created in an Oracle tool called discoverer.
> I have realized a programmatic way to export all Oracle query names in an excel spreadsheet
> then i import the excel spreadsheet into Access to give the user a different
> front door by which to execute these queries via a .bat file)
>
> c) A straightforward use of tabbed forms is to spread out fields from THE SAME record across tabs for readability.
>
> d) In my case, i want to have 4 tabs that represent DIFFERENT RECORDS types
> in the same table called TBL_Tag.
>
> Because, i want the user to be able to create tags of 4 different flavors such as:
> Search query by:
> User
> office Function
> Field
> Programmer technique
>
> tab 0 = "User" - any records would be written to TBL_tag with key of 10
> tab 1 = "Office Function" - any records would be written to TBL_tag with key of 20
> tab 2 = "Field" - any records would be written to TBL_tag with key of 30
> tab 3 = "Programmer" - any records would be written to TBL_tag with key of 40
>
> e) i assigned to each tab a tag property with
> 10,20,30, 40
>
> f) each tab has the same subform
>
> g) when user click the tab, would like the subform to filter or set its record
> source for the tag rows that match the query name and the tag property from step (e)
>
> strWhereSql = " WHERE Tag_Type = " & Me.tabContainer.Pages(0).Tag & _
> " AND " & _
> " Tag_QueryName = " & varQuote(Me.txtHiddenQueryName)
>
>
> I tried so many different ideas in the Tab's change event,
> and am getting run time errors.
>
> Just uploaded a test mdb in a zip file called Sandra's file - subform on tab control..
>
> Please click FRM_001_MenuDiscoverer
> The first query is already highlighted: aaa_DiscovererReports
> so just click button: Assign Tags
>
> that takes you to: FRM_015_QueryTag_Tab
> with subform: sfrm_015_QueryTag
> subform ctl : ctl_subf
>
> The first tab needs to filter just to show jsmith, instead the tab is showing all record types for this query
> name.
>
> any help you can provide would be greatly appreciated, tx, sandra
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar