Discussions

Changing the Record Source of a form on button click in MS Access

+
0 Votes
Locked

Changing the Record Source of a form on button click in MS Access

PeterFis
My ignorance of VB (that I see as complex and daunting) stands in stark contrast to my perception that Access is simple and straight forward in many cases.

I have a form that has a Record Source (being a Query I created under a name, so it is listed in my set of Queries) and it displays exactly the set of Records that I expect.

But I now have the need to display a single record that I have found through another form, a Search form. I write its result to a Context Table. Having created a variation of my query to only display that one record, I see the elegant solution as simply substituting the Record Source name property in the form that displays the details with my alternate Query name.

Problem is I do not know how I can change the value of a Property through code. How do I interact with the properties of a form?

All I need to do is have a button on my Search form that has an On-Click Event Proc that substitutes the name, then opens the details form to list only that one Row. Later I will reinstate the original Record Source; using the vital input I hope to obtain here.

After lengthy searches I have found no answer to what I see as a very common need, that is, how to change values (or arguments?) of Form Properties.

I am hoping that someone who has the answer (and I am sure many do) will care to respond and make my day. And I will greatly appreciate your time. Because it's valuable for all of us.