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

Change form recordsource OR make multiple identical forms?

Status
Not open for further replies.

votegop

Technical User
Feb 22, 2002
127
US
I have a form that I could make copies of and change each copy's recordsource to one of my different queries. Alternatively, I could code changes in recordsource for just ONE form.

The latter seems better for long-term maintenance. I'll only have to make changes to (1) form, rather than many. (I've actually developed my db using the prior, but I tire of "copy/paste/change the record source" every time I tweak the form (which is a work in progress). Before I commit to changing my db to the single-form scenario, I'd like to hear some feedback.

Any reason I should fear such a change?
 
I've done something similar where I have added a subform (MySubForm) and a list box (MyListBox). I populated the list box with the appropriate tables/queries I wanted to include and then in its Before Update event I updated the Source Object of the subform.

ie
MySubform.SourceObject = [MyListBox].Value

or

MySubform.SourceObject = "tblMyTable1" 'and so on...

[yinyang]
 
Just make one form, and change the record source.

The first database I made (which I'm still using), has a different form and report (and query) for everything - even though they're all basically the same. Now, I've got about fifty queryies, and I can't remember what does what. It's a mess for maintenance.

 
Thanks GDGarth & Shannon1. I thought I'd get a response like "you actually make seperate forms?". Glad to hear someone can relate. Unless I hear otherwise, I'm converting!
 
I go about this slightly askew for the approach given so far. In situations which require a different recordsource, there is (for my apps) a predecessor of some type (swithboard, previous functional form, ...) where it is possible to know the criteria for the form to be opened.

Simply use the criteria to set the forms' recordseource to the proper source. For example, there might be a form (MyForm) used by bob, mary and sue. It is instantiated from a switchboard, where the user is already known. The FORM has a recordsource "qryMyUser", so in the OnClick even of the switchboard which opens MyForm, I 'write' qryMyUser, to retrieve the records for the specific User BEFORE opening the form.

Of dcourse, this simplistic example is not really different from having all of the records in common tables and simply having the recordsources filtered by the user name, or the various queries include the username in a where clause.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Hi,

I have tried implementing the second method of changing the rowsource depending which source table I want to display on the common form. However I haven't found the correct place to change the rowsource value, as when I tried it in the OnLoad event, this works except if the form is already open when the calling button tries to open the form.

Where has everyone else changed the rowsource?

My first attempt was to change the filter parameter in the openform call, but access seems to ignore this when the base table is different to the one stored in the default rowsource property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top