Changing Recordsource for Form

  • Thread starter Thread starter Kitty
  • Start date Start date
K

Kitty

I apologize for the wordiness of my question. I'm having
trouble being concise.

I have a form that displays 16 different facets of a
portfolio. The user selects an option from a group on a
form, and depending on the selection, the form shows the
applicable records.

Most of the forms are populated from one table with
filters applied through a macro. Two of those options
open duplicates of the main form based on different tables
with the same exact table structure (the base set of
records populating the tables is different). The only
difference in the forms is the recordsource.

I'm trying to change the recordsource depending on the
selection, and have just one form.

The code I have behind one of the unique selections is:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qmakSampleSelectionReportAdHoc"
Me.Form.RecordSource = "tblAdHocSampleSelectionReport"
DoCmd.OpenForm "frmSAmpleSelectionPreview"
DoCmd.SetWarnings True

The form populates with the correct data from the AdHoc
table EXCEPT the TITLE on the form does not change from
whatever option was selected previously. The title on the
form comes from a Report_Name field in the table. If, in
this case, the AdHoc option is selected first, the name on
the form is blank.

The master form is bound to a table called tblLRMCutOff.

Help!

Thanks for your suggestions.

Kitty
 
Try requerying the Title control:

Me.Title.Requery

BTW, I'm a little concerned about your method overall. Repeated use of
MakeTable queries will cause a lot of database bloat over the long run. You
might better programmatically create a query to use as your RecordSource.

On my website (www.rogersaccesslibrary.com) is a small Access database
sample which illustrates one way to do this. It is called:
"ImproveFormPerformance2k.mdb"

--
--Roger Carlson
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Bloat is an issue with this database for many reasons, and
users know to compact it (it's not network-based and is
single-user on a person's computer as it has to be usable
when nowhere near a network). They get reminded to
compact periodically by the program.

The data for the form comes from multiple tables, and
there are fields that have to be updatable. After the
user does the input, there are update queries that run to
make the changes in the various tables, then the form's
record source table is deleted. Hard to explain, but
through years of working with the data and the users, this
has evolved as the easiest and most efficient way to work
with the situation.

I'll try to requery the field and see if it works.

Thanks!
 
Back
Top