Change Recordsource on Hidden Form

  • Thread starter pic078 via AccessMonster.com
  • Start date
P

pic078 via AccessMonster.com

For optimization purposes, I have a bound form (tied to a saved query) that
preloads in hidden mode at startup - I make this form visible/invisible via
code, rather than constantly closing/re-opening the form while the
application is in use.

My question is: How do I change the recordsource behind a hidden bound form
prior to making it visible? What's the best approach?

(I'm reducing the number of records bound to the the form to one, based on
user input from another bound form - since there is no need to edit/update
more than one record at a time)

I have tried various techniques, such as modfiying the querydef of the saved
query to which the form is bound. However, the form either remains invisible
when I try to make it visible, or when the form actually appears, the form
does not display the correct information. Do I need to requery the form or
set the form recordsource property to the modified SQL every time the form is
made visible?

Any feedback would be greatly appreciated.

-Chris
 
M

Marshall Barton

pic078 said:
For optimization purposes, I have a bound form (tied to a saved query) that
preloads in hidden mode at startup - I make this form visible/invisible via
code, rather than constantly closing/re-opening the form while the
application is in use.

My question is: How do I change the recordsource behind a hidden bound form
prior to making it visible? What's the best approach?

(I'm reducing the number of records bound to the the form to one, based on
user input from another bound form - since there is no need to edit/update
more than one record at a time)

I have tried various techniques, such as modfiying the querydef of the saved
query to which the form is bound. However, the form either remains invisible
when I try to make it visible, or when the form actually appears, the form
does not display the correct information. Do I need to requery the form or
set the form recordsource property to the modified SQL every time the form is
made visible?


You can either construct a new record source SQL statement
or change the querydef's SQL property and requery the form.

I recommend constructing the record source SQL statement.
Setting the RecordSource property will automatically requery
the form. Changing the querydef modifies a saved object and
is just the long way around to achieving the same thing.

As long as the form is open, I do not understand why the
form would not become visible when you set its Visible
property to True.
 
P

pic078 via AccessMonster.com

Thanks for your response. I constructed the new SQL statement based on
user's selection on first form, hooked it up to the preloaded form by setting
the recordsource - however, the form was still not visible when I set the
visible property to true...

Then I fgured out the problem: the first form's modal property was set to
true; when I disabled this, and added code to set focus to preloaded form
once visible - everything worked fine.



Marshall said:
For optimization purposes, I have a bound form (tied to a saved query) that
preloads in hidden mode at startup - I make this form visible/invisible via
[quoted text clipped - 14 lines]
set the form recordsource property to the modified SQL every time the form is
made visible?

You can either construct a new record source SQL statement
or change the querydef's SQL property and requery the form.

I recommend constructing the record source SQL statement.
Setting the RecordSource property will automatically requery
the form. Changing the querydef modifies a saved object and
is just the long way around to achieving the same thing.

As long as the form is open, I do not understand why the
form would not become visible when you set its Visible
property to True.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top