Supposing I wanted to do something like this:
Set rsB = db.OpenRecordse t("qryStuff")
only qryStuff required parameters? How do I pass the parameter values to the query?
Thanks. 4 3442
You can assign values to the Parameters of the QueryDef before you
OpenRecordset:
Dim qdf As QueryDef
Set qdf = dbEngine(0)(0). QueryDefs("qryS tuff")
qdf.Parameters( "SomeParameter" ) = 4
Set rsB = qdf.OpenRecords et()
Another alternative is to just build the SQL statement dynamically instead
of worrying about saving a QueryDef with parameters.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Weaver" <we*****@verizo n.net> wrote in message
news:66******** *************** ***@posting.goo gle.com... Supposing I wanted to do something like this:
Set rsB = db.OpenRecordse t("qryStuff")
only qryStuff required parameters? How do I pass the parameter values to the query?
Thanks.
Thanks again Allen. But I'm not clear on a couple of things here.
Whats with this part:
dbEngine(0)(0).
I'm not familiar with that syntax.
Also, how do I cause the form to display the recordset that we're
manipulating here? Is it just:
SomeForm.Record set = rsB
Chris.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >... You can assign values to the Parameters of the QueryDef before you OpenRecordset: Dim qdf As QueryDef
Set qdf = dbEngine(0)(0). QueryDefs("qryS tuff") qdf.Parameters( "SomeParameter" ) = 4 Set rsB = qdf.OpenRecords et()
Another alternative is to just build the SQL statement dynamically instead of worrying about saving a QueryDef with parameters.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Weaver" <we*****@verizo n.net> wrote in message news:66******** *************** ***@posting.goo gle.com... Supposing I wanted to do something like this:
Set rsB = db.OpenRecordse t("qryStuff")
only qryStuff required parameters? How do I pass the parameter values to the query?
Thanks.
dbEngine is the top of the tree in the DAO object model - the library that
Access is based on internally. Details and examples in:
DAO: Data Access Objects
at: http://members.iinet.net.au/~allenbrowne/ser-04.html
If this is heading for a form, you could set the RecordSource of the form to
the changed query, but you don't really need the query. Instead, just build
the SQL string and assign it to the form's RecordSource. Example:
Dim strSql as String
strSql = "SELECT * FROM MyTable WHERE SomeField = 4;"
Me.RecordSource = strSql
Alternatively, you could set the Filter property of the form instead of
worrying about the parameters at all.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Weaver" <we*****@verizo n.net> wrote in message
news:66******** *************** ***@posting.goo gle.com... Thanks again Allen. But I'm not clear on a couple of things here.
Whats with this part:
dbEngine(0)(0).
I'm not familiar with that syntax.
Also, how do I cause the form to display the recordset that we're manipulating here? Is it just:
SomeForm.Record set = rsB
Chris.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >... You can assign values to the Parameters of the QueryDef before you OpenRecordset: Dim qdf As QueryDef
Set qdf = dbEngine(0)(0). QueryDefs("qryS tuff") qdf.Parameters( "SomeParameter" ) = 4 Set rsB = qdf.OpenRecords et()
Another alternative is to just build the SQL statement dynamically instead of worrying about saving a QueryDef with parameters.
"Weaver" <we*****@verizo n.net> wrote in message news:66******** *************** ***@posting.goo gle.com... > Supposing I wanted to do something like this: > > Set rsB = db.OpenRecordse t("qryStuff") > > only qryStuff required parameters? How do I pass the parameter values > to > the query? > > > Thanks.
Filter is the way I'd gone from the beginning. Somehow I thought that
a parameterized query would be more efficient. I'll stay with the
Filter; it works.
In regard to dbEngine, it's the (0) (0) part that had me puzzled.
I am posting another question to this forum regarding a far more
generic question that has me stymied. I'll probably call it 'Posting
error'. Have a look if you get the chance.
Thanks,
Chris.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<41******* *************** *@per-qv1-newsreader-01.iinet.net.au >... dbEngine is the top of the tree in the DAO object model - the library that Access is based on internally. Details and examples in: DAO: Data Access Objects at: http://members.iinet.net.au/~allenbrowne/ser-04.html
If this is heading for a form, you could set the RecordSource of the form to the changed query, but you don't really need the query. Instead, just build the SQL string and assign it to the form's RecordSource. Example: Dim strSql as String strSql = "SELECT * FROM MyTable WHERE SomeField = 4;" Me.RecordSource = strSql
Alternatively, you could set the Filter property of the form instead of worrying about the parameters at all.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Weaver" <we*****@verizo n.net> wrote in message news:66******** *************** ***@posting.goo gle.com... Thanks again Allen. But I'm not clear on a couple of things here.
Whats with this part:
dbEngine(0)(0).
I'm not familiar with that syntax.
Also, how do I cause the form to display the recordset that we're manipulating here? Is it just:
SomeForm.Record set = rsB
Chris.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >... You can assign values to the Parameters of the QueryDef before you OpenRecordset: Dim qdf As QueryDef
Set qdf = dbEngine(0)(0). QueryDefs("qryS tuff") qdf.Parameters( "SomeParameter" ) = 4 Set rsB = qdf.OpenRecords et()
Another alternative is to just build the SQL statement dynamically instead of worrying about saving a QueryDef with parameters.
"Weaver" <we*****@verizo n.net> wrote in message news:66******** *************** ***@posting.goo gle.com... > Supposing I wanted to do something like this: > > Set rsB = db.OpenRecordse t("qryStuff") > > only qryStuff required parameters? How do I pass the parameter values > to > the query? > > > Thanks.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ahokdac-sql |
last post by:
Hi,
I'm adapting access queries to sql server and I have difficulties with
the following pattern :
query1 : SELECT * FROM Query2 WHERE A=@param1
query 2: SELECT * FROM Table2 WHERE B=@param2
The queries are nested, and they both use parameters.
In MS Acccess the management of nested queries with parameters is so
easy (implicit declaration of parameters, transmission of parameters
from main query to nested query)
|
by: Roger Green |
last post by:
I have inherited a complex database that has many dozens of queries that derive data from a people
table.
I now need to be able to run these queries (from within a significant number of forms) not on the
full dataset, but on a subset of the data in the people table.
I want to avoid having to put criteria in all of the individual queries or forms, or having to
change the data source for all the queries.
Is there anyway I can restrict...
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my predecessor, I hasten to add) so that each day it creates a
copy of the record for each company, changes the date to today's date,
and prompts the user for any changes of ratings on that day. The
resulting data table grows by approx 600 records per...
|
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 server ?
Is it possible to use parameters in pass-through queries ?
An additional question: Is it possible to connect to a database on MySQL or
PostgreSQL using ADO ?
Is it possible to execute pass-through queries with parameters, using ADO...
|
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 appear when someone is trying to use it as front-end for real
server database systems such as PostgreSQL or MySQL.
One of these problems is regarding pass-through queries and parameters.
I wanted to have all the code on client, while executing it on...
| |
by: deko |
last post by:
Is it possible to build a parameterized query from another parameterized
query?
I've tried two variations of this and can't seem to get it to work (using
DAO). Any suggestions welcome!
I want to delete linked documents - but only if they are not
linked to other entities outside of the category being deleted
|
by: Dirk Vervecken |
last post by:
Hi i've got an application in dotnet that uses
queries from an Access database.
Now most of the common select statements return the desired data,
however, one the queries requires a parameter.
This particular queries does not return the correct data.
I've tested the query in access and it works.
Somehow the parameter that I pass from asp.net does not seem
to be arriving.
This is a sample query of how it looks:
|
by: Roy |
last post by:
Hey all,
Here's a small VB codeblock that connects to a database and uses 2 SQL
queries then forms a relation for a master/detail view on the aspx side:
Private Sub Binddata(ByVal name As String)
Dim myconn As New
SqlConnection("server=localhost;uid=ser;pwd=none;database=et")
Dim mycom As New SqlCommand("select * from tbl1;select * from tbl2",
|
by: =?Utf-8?B?Sm9uIEphY29icw==?= |
last post by:
For MS SQL Server...
I am used to declaring local variables in my SQL queries...
Declare @MyInt int, @MyChar varchar(33)
Parameters were idenfitied with a colon...
Where ModDate :MyDate
But, now that I am stwitching to .NET, the parameters are identified with @
in SqlCommand, so how do I declare local variables in my queries (like in
Query Analyzer)?
|
by: MMcCarthy |
last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access.
Angle brackets <> are used in place of some syntax elements you must supply. The description of these elements will be in the contained in the angle brackets.
Square brackets are used to show which parts are optional.
Basic SELECT query
SELECT <field list>
FROM <table/query name(s)>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |