473,397 Members | 1,969 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,397 software developers and data experts.

VBA SQL Statement

I am a newbie in Access and I have created a unbound report and am
trying to get data from 2 different queries. Previously, I had used the
ADODB recordset method to get data from tables and I have applied the
same logic to this case but using a query. But, when I try to run the
report I get the following error message: "No value given for one or
more required parameters." My code is as follows:

Dim rsPoles As New ADODB.Recordset
Dim SQLStmt As String

SQLStmt = "SELECT Customer, Poles, Rate from qryPoleTotal"
rsPoles.Open SQLStmt, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
rsPoles![Customer] = Me.Customer
rsPoles![Poles] = Me.SumOfPoles_
rsPoles![Rate] = Me.Rate
rsPoles.Update
rsPoles.Close
Set rsPoles = Nothing

(The coding is for only one query because I wanted to test it with one
before I added the second.)

I didn't use a WHERE clause because the query already has that logic
and I didn't use a union query because the two queries have different
fields and different data.

Can someone please help me with this problem.

Thank you in advance.

Aug 6 '06 #1
3 4252
Why don't you create the query you wish and bound the record source of
your report to it?

Aug 6 '06 #2
in your example code you open up a reocrdset, but what particular record are
you trying to update (your code example
does not define any particular record you are updating with those form
values. As the code stands, you would ALWAYS be updating the first record in
the qryPoleTotal. Further, is qryPoleTotal a updatable query?

Further, you can't really have a un-bound report, ad do anything useful.
Further, you made no case as to why your report needs to be un-bound.

Perhaps you are trying to append data to a temporary table that qryPoleTotal
is based on? And then base the report on that table? This would NOT be what
we call a un-bound report, but simply a report bound to a table that we plan
to send data to. This is possible, but a un-bound report is not useable..
I didn't use a WHERE clause because the query already has that logic
That does not matter. If you send the report a where clause...it will simply
operate on the report, regardless if that query the report is based on
already has some conditions. So, once again, the above assumption don't
support not using a where clause.

Your code example (if we get it to work) simply updates the first record in
the table that qryPoleTotal is based on.

What good comes from simply modifying the first record of qryPoleTotal?
Further, is there any existing records that the qeryPoletotal returns?

Is qryPoleTotal based on a empty table? Are you trying to update just one
record here...or many?

If you need the report to display data from more then one table, you have
several choices

If the data is columnar in nature, and you have many records from the
two tables, but can match up the fields, then a union query is a good
choice. another choice would be to use the temp table, and use two append
queries to merge the data into a single table. Both of these approaches can
deal with different field names, and map them to a common set of fields for
the report (however, this approach does increase the amount of maintains and
as a good rule, you should avoid temp tables).

If the two tables are really different data and require somewhat
different report format, then in a sense you want to display two different
reports on one report. If this is your case, then simply place/use two
sub-reports on a main report. This works quite well.

Do feel free to expand a bit here, as I may have miss-understood you
goal/problem here....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 6 '06 #3
I didn't realize that the method I was using was for only updating
records. I tried out the subreport method an it worked. Thank You.
Albert D. Kallal wrote:
in your example code you open up a reocrdset, but what particular record are
you trying to update (your code example
does not define any particular record you are updating with those form
values. As the code stands, you would ALWAYS be updating the first record in
the qryPoleTotal. Further, is qryPoleTotal a updatable query?

Further, you can't really have a un-bound report, ad do anything useful.
Further, you made no case as to why your report needs to be un-bound.

Perhaps you are trying to append data to a temporary table that qryPoleTotal
is based on? And then base the report on that table? This would NOT be what
we call a un-bound report, but simply a report bound to a table that we plan
to send data to. This is possible, but a un-bound report is not useable..
I didn't use a WHERE clause because the query already has that logic

That does not matter. If you send the report a where clause...it will simply
operate on the report, regardless if that query the report is based on
already has some conditions. So, once again, the above assumption don't
support not using a where clause.

Your code example (if we get it to work) simply updates the first record in
the table that qryPoleTotal is based on.

What good comes from simply modifying the first record of qryPoleTotal?
Further, is there any existing records that the qeryPoletotal returns?

Is qryPoleTotal based on a empty table? Are you trying to update just one
record here...or many?

If you need the report to display data from more then one table, you have
several choices

If the data is columnar in nature, and you have many records from the
two tables, but can match up the fields, then a union query is a good
choice. another choice would be to use the temp table, and use two append
queries to merge the data into a single table. Both of these approaches can
deal with different field names, and map them to a common set of fields for
the report (however, this approach does increase the amount of maintains and
as a good rule, you should avoid temp tables).

If the two tables are really different data and require somewhat
different report format, then in a sense you want to display two different
reports on one report. If this is your case, then simply place/use two
sub-reports on a main report. This works quite well.

Do feel free to expand a bit here, as I may have miss-understood you
goal/problem here....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
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...
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
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.