473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

pass parameter to query in vba

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
7 19666
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Belinda | last post by:
Hello All I have the following test.asp page which needs one parameter querystr but my querystr is a very long string value. When I send a long value the query string is getting truncated after...
5
by: Don Seckler | last post by:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
9
by: Alan Silver | last post by:
Hello, I'm a bit surprised at the amount of boilerplate code required to do standard data access in .NET and was looking for a way to improve matters. In Classic ASP, I used to have a common...
1
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control...
2
by: Roger | last post by:
Anyone know how to pass a parameter to a query via a report in Access 2003?
2
by: Dud Bug | last post by:
I have a query in an Access db that prompts the user for info. (e.g. a primary key representing a company) before compiling the relevant table of results. This works fine in Access but I want to use...
1
by: Mayhem05 | last post by:
I have an Access 2003 database that I need to write some VBA code for to populate a table. The table is based on a query I have built in Access queries. Right now I have 2 parameters that are...
1
by: woody | last post by:
I have a bit of a newbie question (basically stated in the subject of the posting). If need to get some data out of a SQL Server Database. Can I use a control from a form to supply a parameter. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.