I'm attempting to use the DSum function to get the sum of selected records. However, when I try to assign this number to a variable, I get error number 3163: The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. I have verified that the query string gets the correct results and that the summed field exists. Here is my code: - Dim lngSelectionTotal As Long
-
Dim strSelected As String
-
-
strSelected = "SELECT tblAnswerLevel.ID, tblAnswerLevel.CrimeID_fk" & _
-
", tblAnswer.Selection, tblQuestion.QValue " & _
-
"FROM tblAnswerLevel INNER JOIN " & _
-
"(tblQuestion INNER JOIN tblAnswer ON tblQuestion.QuestionID = tblAnswer.QuestionID_fk) " & _
-
"ON tblAnswerLevel.ID = tblAnswer.AnswerLevelID_fk " & _
-
"WHERE tblAnswerLevel.ID = " & Me.ID & " AND tblAnswer.Selection = True"
-
-
lngSelectionTotal = DSum("QValue", strSelected)
I checked the data type in the table and it is Long Integer. In this particular case, the DSum() value returned should be 4. Not sure how this is too big. At first I had my variable be an integer and then I changed it to long since it was saying that the field was too small. Didn't change anything. I then tried to just find out what number it was returning in the immediate window by entering - ?DSum("QValue", strSelected)
I got the same error. So this leads me to believe that it has nothing to do with the variable data type having enough room to hold the number returned.
I looked up the error number through MSDN, but it basically said that you will get this error if the number is over 100 characters, which 4 is one hundredth of that. Here is a link to the website: Error 3163. I have never gotten this error before and don't know where to go from here as I don't see my data matching the "cause" of this error according to MSDN.
4 2615 zmbd 5,501
Recognized Expert Moderator Expert
expression.DSum (Expr, Domain, Criteria)
(...)Domain Required String A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.(...)
You can not use an SQL string at this point. Surprised a debug compile didn't choke on you... although, in this case, it would be looking for a table or query named for the resolved value in the string.
Just another example of MS technically correct and yet totally useless error messages.
So basically, I need to take the WHERE clause out of the query and put it in the DSum() function, make my query a querydef, and reference my query in the DSum(). I will try it.
Having tried it, IT WORKS! I ended up having to surround the DSum() function with the Nz() function to handle Nulls.
I wouldn't have guessed that it could ONLY be a table name or query name. I thought that I had used a SQL string in the DLookup() function, but I could be wrong on that. And no, I didn't get a compile error.
Thanks for your help Z.
zmbd 5,501
Recognized Expert Moderator Expert
You are correct.
You can use strings in each section of the D*() functions; however, the first string must evaluate to the Name of a Field within the Table/Query referenced in the second section. The string in the second section can be a string; however, it must resolve to the Name of a Table or resolved Query - you can't even use a recordset opened within code unless it has been added to the qrydef. The funny thing, you can use a string in the criteria section of the D*() functions so long as the string evaluates to a valid "WHERE" clause.
NeoPa 32,569
Recognized Expert Moderator MVP Seth:
I wouldn't have guessed that it could ONLY be a table name or query name. I thought that I had used a SQL string in the DLookup() function, but I could be wrong on that.
If you check the Help pages you'll find that all Domain Aggregate functions ( D*() ) take only object (Table or QueryDef) names for the Domain parameter. No SQL strings. It does seem a shame, but there it is.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: PA |
last post by:
Hi All,
Thanks for your attention..I appreciate that.
-----Problem description -----------Start----------------------
Database : DB2 UDB 8.2 on Windows 2003
Client: VB6/ADO 2.7 on Windows 2003
1) I am opening a ADO 2.7 recordset with following settings
|
by: nagaraj_hayyal |
last post by:
hi all,
i am a c++ developer facing a problem with DB2-CLI on AIX5.2.
we are using db2 v8 fixpak 10, gcc 3.3.2, on aix5.2 with extensive use
of STL vectors.
we are using ODBC 3.0 for our applications.
the exception we are getting is "function sequence error cli0125E".
we are using multithreaded applications which uses pthread library.
with single thread the application works fine without any such
exceptions.
but when we execute with...
|
by: seanseaghan |
last post by:
New to this group, so greetings all!
I am trying to develop query syntax in Access 2000 to accomplish the
following:
Imagine you are in an accounting dept. and you are working on a
reconiliation of debits and credits.
Say you have a table / list that is 1000s of lines long. These could
be either debits or credits. Then imagine you know that a certain
|
by: tommydkat |
last post by:
Hi! I'm updating a Windows application that we develop that uses a DB2
database. We switched from using Microsoft Developer Studio 6 to
Visual Studio .Net 2003 to build our app and since that switch, we've
been getting a function sequence error with this SQLSTATE:
State:S1010,Native:0,Origin:
Here is a sample query we're running that generates the error
UPDATE TOM.USERS SET TYPE=TYPE WHERE 1 = 0
|
by: ckpoll2 |
last post by:
Hi,
I have made a report that has a query as its record source. I put a text box in there that I want to run a dsum function off of a different query. The criteria that I need to use is that it returns the appropriate number for whatever name appears in the Name text box within the Name Header. Here's the formula I have:
=DSum("","Overtime","Name=")
All it's giving me is the sum for everyones hours in the overtime query in each...
| |
by: technocraze |
last post by:
Hi community experts,
I am having an isue with Dsum function that is used to count the total number for a particular field (intake) at the textbox afterupdate event with condition/ criteria (subject). Below is the scenario in details.
What I need to do is summing the intake corresponding to what is selected from the dropdown combo box. For instance if the user choose maths in the combo box, the total no of intake should be displayed in...
|
by: zaiena |
last post by:
hello,
i'm having this problem when try to display the total amount form subform to form,for example i'm having two tables one for the products which contains(p_no,p_name,price),and the other table contains(p_no,total_price,total_amount)
so the first table is placed in subform and the other table is placed in the main form,i wanna to calculate the total (price) in subform and display the result in the (total_price) field in main form,i'm tryin...
|
by: JRough |
last post by:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource on line 157"
This is the function call on line 123:
$data .= makexcldata($str1);
Line 157 is the first line of the While loop.
|
by: wassimdaccache |
last post by:
dears
I have a continuous forms. It contains 2 fields
I made another field to check their accounts. it is .
the source of is based on a DSUM function. "it is working well"
Now I want to filter this form on a criteria where account > 0.
It is not working using this code
|
by: Gulnarambi |
last post by:
I have a form in datasheet view with Total and Currency text boxes, in Currency text box I only can enter values of AZN and USD.
Form is based on Table and as criterias information fromUnbound control from another form is used,
In form footer I need to create too text boxes, one of then shoul calculate sum of Total for records where currency field equals to USD and other one calculates sum for Total for records where Currency field equals to...
|
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: 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: 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |