A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can recordsource parameters be set in code?



 
 
Thread Tools Display Modes
  #1  
Old June 15th, 2004, 02:25 AM
external usenet poster
 
Posts: n/a
Default Can recordsource parameters be set in code?

I'm using Access 97. I have a subform, and the
RecordSource of the subform is a query that contains a
parameter. I am prompted to enter the value of the
parameter every time I navigate to a different record in
the parent form. However, I want to set the parameter's
value in code, avoiding manual entry.

I need to set the parameter value, and requery the
subform, every time the parent form navigates to a new
record. Can this be done in code? The value of the
parameter is a field that is available in the parent form.

The link master/link child properties don't solve my
problem because the recordsource of the subform is a
union query, and performance is unacceptable when I rely
on link master/link child properties. The root cause of
this performance probelm is illustrated by the following
two queries. They are equivalent, but the first one
executes MUCH faster:

Select * From Q1 Where Fld = value_1 UNION
Select * From Q2 Where Fld = value_1


Select * From
(Select * From Q1 UNION Select * From Q2)
Where Fld = value_1

The second query is effectively what I get when I use the
link master/link child properties. So, I want to use a
parameter in the query and set it in code.
Thanks,
Paul
  #2  
Old June 15th, 2004, 04:56 AM
John Vinson
external usenet poster
 
Posts: n/a
Default Can recordsource parameters be set in code?

On Mon, 14 Jun 2004 18:25:58 -0700,
wrote:

I need to set the parameter value, and requery the
subform, every time the parent form navigates to a new
record. Can this be done in code? The value of the
parameter is a field that is available in the parent form.


Just use that control as (part of) the Subform's Master Link Field,
and the field that it is searching as the Child Link Field. Or,
explicitly reference the form control in the parameter:

=[Forms]![yourformname]![controlname]


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.