By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

pass parameter to query in vba

P: n/a
I need to pass a parameter to the source query of a subform via vba.
Any ideas on how to do that?

(Actually I wanted to set the subform source to a query but I guess
that isn't possible.. )

Greetzzz
Liezzzje...
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Liezzzje,
You can assign a (new) recordsource for your subform in runtime
Use following syntax:
Me!SubformControlName.Recordsource="MyQueryName"
Your subform will be requery'd also

--
Hope this helps
Arno R
"Annelies" <an**************@hotmail.com> schreef in bericht
news:c7**************************@posting.google.c om...
I need to pass a parameter to the source query of a subform via vba.
Any ideas on how to do that?

(Actually I wanted to set the subform source to a query but I guess
that isn't possible.. )

Greetzzz
Liezzzje...

Nov 12 '05 #2

P: n/a
So if I had a form called Form_patient with a subform called sub75 and
I wanted to set the subform's source from another form, the syntax
would be :
Form_patient!sub75.recordsource="MyQueryName"
?? If that's correct then I have a problem because recordsource isn't
in the possibilities I get after typing the dot :)
Any suggestions?

Greetz..

"Arno R" <ar****************@tiscali.nl> wrote in message news:<bk**********@reader1.tiscali.nl>...
Liezzzje,
You can assign a (new) recordsource for your subform in runtime
Use following syntax:
Me!SubformControlName.Recordsource="MyQueryName"
Your subform will be requery'd also

--
Hope this helps
Arno R
"Annelies" <an**************@hotmail.com> schreef in bericht
news:c7**************************@posting.google.c om...
I need to pass a parameter to the source query of a subform via vba.
Any ideas on how to do that?

(Actually I wanted to set the subform source to a query but I guess
that isn't possible.. )

Greetzzz
Liezzzje...

Nov 12 '05 #3

P: n/a
an**************@hotmail.com (Annelies) wrote in
news:c7**************************@posting.google.c om:
So if I had a form called Form_patient with a subform called
sub75 and I wanted to set the subform's source from another
form, the syntax would be :
Form_patient!sub75.recordsource="MyQueryName"
?? If that's correct then I have a problem because
recordsource isn't in the possibilities I get after typing the
dot :) Any suggestions?


The correct syntax is:
Forms!Form_patient!sub75.form.recordsource="MyQuer yName"

Bob

Nov 12 '05 #4

P: n/a
Annelies,
read this article:
http://www.mvps.org/access/forms/frm0031.htm

There's an example of how to do what you want in there. You could do
this in one of two ways:

with a parameterized query, where you do something like

qdf.Parameters(0)=Forms!MyLoadedForm!MyControl.Val ue

or in the WHERE statement...
Nov 12 '05 #5

P: n/a
Oeps !! As Bob already corrected I forgot the '.form' statement.
My example should be: Me!SubformControlName.Form.Recordsource="MyQueryNa me"
Sorry for the mistake I made.

Arno R
"Annelies" <an**************@hotmail.com> schreef in bericht
news:c7**************************@posting.google.c om...
So if I had a form called Form_patient with a subform called sub75 and
I wanted to set the subform's source from another form, the syntax
would be :
Form_patient!sub75.recordsource="MyQueryName"
?? If that's correct then I have a problem because recordsource isn't
in the possibilities I get after typing the dot :)
Any suggestions?

Greetz..

"Arno R" <ar****************@tiscali.nl> wrote in message

news:<bk**********@reader1.tiscali.nl>...
Liezzzje,
You can assign a (new) recordsource for your subform in runtime
Use following syntax:
Me!SubformControlName.Recordsource="MyQueryName"
Your subform will be requery'd also

--
Hope this helps
Arno R
"Annelies" <an**************@hotmail.com> schreef in bericht
news:c7**************************@posting.google.c om...
I need to pass a parameter to the source query of a subform via vba.
Any ideas on how to do that?

(Actually I wanted to set the subform source to a query but I guess
that isn't possible.. )

Greetzzz
Liezzzje...

Nov 12 '05 #6

P: n/a
Bob Quintal <bq******@generation.net> wrote in message news:<20******************************@news.terane ws.com>...
an**************@hotmail.com (Annelies) wrote in
news:c7**************************@posting.google.c om:
So if I had a form called Form_patient with a subform called
sub75 and I wanted to set the subform's source from another
form, the syntax would be :
Form_patient!sub75.recordsource="MyQueryName"
?? If that's correct then I have a problem because
recordsource isn't in the possibilities I get after typing the
dot :) Any suggestions?


The correct syntax is:
Forms!Form_patient!sub75.form.recordsource="MyQuer yName"

Bob


I get error #2467 :s

Greetzzz..
Nov 12 '05 #7

P: n/a
an**************@hotmail.com (Annelies) wrote in message news:<c7**************************@posting.google. com>...
I need to pass a parameter to the source query of a subform via vba.
Any ideas on how to do that?

(Actually I wanted to set the subform source to a query but I guess
that isn't possible.. )

Greetzzz
Liezzzje...


anybody an idea how to solve error 2467??
Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.