the field is too small to accept the data you wanted to add. try inserting or pasting less data - ms-access-2007

SELECT net1.hhid, net1.prod_price, net2.seed, net3.lph_labour, net4.crop_labour, net5.fer_cost, net6.pes_cost, net7.seed_labour, net8.irr_cost,
(net2.seed+net3.lph_labour+net4.crop_labour+net5.fer_cost+net6.pes_cost+net7.seed_labour+net8.irr_cost) AS cost,
(net1.prod_price-cost) AS net_profit
FROM net1, net2, net3, net4, net5, net6, net7, net8
WHERE net1.hhid=net2.hhid And net1.hhid=net3.hhid And net1.hhid=net4.hhid And net1.hhid=net5.hhid And net1.hhid=net6.hhid And net1.hhid=net7.hhid And net1.hhid=net8.hhid And net1.country=net2.country And net1.country=net3.country And net1.country=net4.country And net1.country=net5.country And net1.country=net6.country And net1.country=net7.country And net1.country=net8.country;
The error message states that the
field is too small to accept the amount of data you attempted to add. try inserting or pasting less data
What is wrong with my code? I need to add the column vales of net1 to 8 queries, in which there hhid and country should be equal.

Related

MS Access-Return Record Below Current Record

I am very new to Access, and what I am trying to do seems like it should be very simple, but I can't seem to get it.
I am a structural engineer by trade and am making a database to design buildings.
My Diaphragm Analysis Table includes the fields "Floor_Name", "Story_Number", "Wall_Left", and "Wall_Right". I want to write a new query that looks in another query called "Shear_Wall_incremental_Deflection" and pulls information from it based on input from Diaphragm Analysis. I want to take the value in "Wall_Right" (SW01), find the corresponding value in "Shear_Wall_incremental_Deflection", and report the "Elastic_Deflection" corresponding to the "Story_Below" instead of the "Story_Number" in the Diaphragm Analysis Table. In the case where "Story_Number" = 1, "Story_Below" will be 0 and I want the output to be 0.
Same procedure for "Wall_Left", but I'm just taking it one step at a time.
It seems that I need to use a "DLookup" in the expression builder with TWO criteria, one that Wall_Right = Shear_Wall and one that Story_Number = Story_Below, but when I try this I just get errors.
"Shear_Wall_incremental_Deflection" includes shearwalls for all three stories, i.e. it starts at SW01 and goes through SWW for Story Number 3 and then starts again at SW01 for Story Number 2, and so on until Story Number 1. I only show a part of the query results in the image, but rest assured, there are "Elastic_Deflection" values for story numbers below 3.
Here is my attempt in the Expression Builder:
Right_Defl_in: IIf(IsNull([Diaphragm_Analysis]![Wall_Right]),0,DLookUp("[Elastic_Deflection_in]","[Shear_Wall_incremental_Deflection]","[Shear_Wall_incremental_Deflection]![Story_Below]=" & [Diaphragm_Analysis]![Story_Number]))
I know my join from Diaphragm_Analysis "Wall_Left" and "Wall_Right" must include all records from Diaphragm_Analysis and only those from "Shear_Wall_incremental_Deflection"![Shear_Walls] where the joined fields are equal, but that's about all I know.
Please let me know if I need to include more information or send out the database file.
Thanks for your help.
Diaphragm Analysis (Input Table)
Shear_Wall_incremental_Deflection (Partial Image of Query)
I think what you are missing is that you can and should join to Diaphragm_Analysis twice, first time to get the Story_Below value and second to use it to get the corresponding Elastic_Deflection value.
To handle the special case where Story_Below is zero, I would write a separate query (only requires one join this time) and 'OR together' the two queries using the UNION set operation (note the following SQL is untested):
SELECT swid.Floor_Name,
swid.Story_Number,
swid.Wall_Left,
da2.Elastic_Deflection AS Story_Below_Elastic_Deflection
FROM ( Shear_Wall_incremental_Deflection swid
INNER JOIN Diaphragm_Analysis da1
ON da1.ShearWall = swid.Wall_Left )
INNER JOIN Diaphragm_Analysis da2
ON da2.ShearWall = swid.Wall_Left
AND da2.Story_Number = da1.Story_Below
UNION
SELECT swid.Floor_Name,
swid.Story_Number,
swid.Wall_Left,
0 AS Story_Below_Elastic_Deflection
FROM Shear_Wall_incremental_Deflection swid
INNER JOIN Diaphragm_Analysis da1
ON da1.ShearWall = swid.Wall_Left
WHERE da1.Story_Below = 0;
I've assumed that there is no data where Story_Number is zero.

Filling 2 records inside of a rowset

I am trying to find out how to fill two seperate records in one rowset to be published to integration broker. I am filling both rowsets seperatly (RS1 for the Level 1 of record Names and RS for the Level 0 record of Person)
&RS1 = CreateRowset(Record.NAMES);
&RS1.Fill("Where emplid=:1 and name_type=:2", &emplid, &nameType);
&RS = CreateRowset(Record.PERSON, &RS1);
&RS.Fill("Where emplid=:1", &emplid);
I have also tried to use this after the above code and the NAMES record didnt show up into the rowset
&RS1.CopyTo(&RS, Record.NAMES, Record.PERSON);
The problem is that when I look at &RS after this runs, the Names record in &RS does not contain any of the name information from &RS1, but the person record is populated. Could anybody help me on how to get this name record in &RS populated with the data from &RS1?
The issue with your code is that &RS1 is really just used to determine the structure of &RS. The actual instantiated rowset is not part of &RS. In the code below note where I get the NAMES rowset for a specific row and assign it to &RS1, then I fill it.
Local Rowset &RS, &RS1;
&RS1 = CreateRowset(Record.NAMES);
&RS = CreateRowset(Record.PERSON, &RS1);
&RS.Fill("Where emplid=:1", &emplid);
&RS1 = &RS(1).GetRowset(Scroll.NAMES);
&RS1.Fill("Where emplid=:1 and name_type=:2", &emplid, &nameType);

Type conversion failure in update query

I'm fairly new to Access so this is driving me a little crazy.
I'm creating an inventory database and want to count the number of items in stock to update an ordering form. Received items are assigned an order code, and I want to count the number of instances of each order code found within the master table. I have a make table query which does this just fine:
SELECT PrimerList.PrimerName
, First(Primer_Master.FR) AS FR
, Primer_Master.OrderCode
, Count(Primer_Master.OrderCode) AS InStock
INTO PrimerOrder
FROM PrimerList
LEFT JOIN Primer_Master ON PrimerList.ID = Primer_Master.PrimerName
GROUP BY PrimerList.PrimerName
, Primer_Master.OrderCode
, Primer_Master.PrimerName
, Primer_Master.FR
, Primer_Master.Finished
HAVING ((([Primer_Master]![Finished])=No));
I want to use PrimerOrder to update an order list table PrimerOrderList which has all of the different possible order codes, updating the InStock value for records with matching OrderCode:
UPDATE PrimerOrderList
SET PrimerOrderList.InStock = PrimerOrder.InStock
WHERE (((PrimerOrderList.OrderCode)=[PrimerOrder].[OrderCode]));
However, when I try to run it I get parameter boxes which pop-up asking for PrimerOrder.OrderCode and PrimerOrderList.OrderCode. Even if I put in a valid value for each, I get a type conversion failure. I've checked the data types for both tables and don't see how there could be a type conversion failure - both are set to text.
Any insight would be greatly appreciated! Thanks in advance!
You haven't included the PrimerOrder table in your query. Should be:
UPDATE PrimerOrderList INNER JOIN PrimerOrder
ON PrimerOrderList.OrderCode = PrimerOrder.OrderCode
PrimerOrderList.InStock = PrimerOrder.InStock

SQL Query not searching data if record contains zero

I have two tables and with column paperNo and some data regarding that paper. I am trying to search all data based on paper no. from both the tables. I have successfully written the query and it is retrieving the data successfully. but I have noticed that. If my paperNo contains zero(0) then the query is not searching for that data. And for the non zero contains paperNo it is retrieving the same record twice.
I don't understand what is going wrong. tried every thing.
Here is my Query .-
SELECT PaperDate.paperNo,
PaperDate.RAW_PAPER,
PaperDate.EDGE_SEALED,
PaperDate.HYDRO_120,
PaperDate.HYDRO_350,
PaperDate.CATALYST_1ST,
PaperDate.CATALYST_2ND,
PaperDate.SIC_350,
tblThicknessPaperDate.rawThickness,
tblThicknessPaperDate.catThickness,
tblThicknessPaperDate.sicThickness,
tblThicknessPaperDate.rejectedThickness
FROM tblThicknessPaperDate
FULL OUTER JOIN PaperDate ON PaperDate.paperNo =tblThicknessPaperDate.paperNo
WHERE (tblThicknessPaperDate.paperNo = #paperNo)
I would try:
FROM tblThicknessPaperDate
RIGHT JOIN PaperDate ON PaperDate.paperNo =tblThicknessPaperDate.paperNo
WHERE (PaperDate.paperNo = #paperNo)
The two changes are: swapping to a right join so even if a record isn't in tblThicknessPaperDate we will still see the record in PaperDate. The other change is to use PapterDate.paperNo in the where clause. Since tblThicknessPaperDate.paperNo could be null we don't want to use that in the where if we can avoid it.
SELECT PaperDate.paperNo,
PaperDate.RAW_PAPER,
PaperDate.EDGE_SEALED,
PaperDate.HYDRO_120,
PaperDate.HYDRO_350,
PaperDate.CATALYST_1ST,
PaperDate.CATALYST_2ND,
PaperDate.SIC_350,
tblThicknessPaperDate.rawThickness,
tblThicknessPaperDate.catThickness,
tblThicknessPaperDate.sicThickness,
tblThicknessPaperDate.rejectedThickness
FROM tblThicknessPaperDate
FULL OUTER JOIN PaperDate ON PaperDate.paperNo =tblThicknessPaperDate.paperNo
WHERE (tblThicknessPaperDate.paperNo = #papNo | PaperDate.paperNo = #paperNo)

ms access 2003 update query sql not working properly

the query is this :
UPDATE ParametersMain2 INNER JOIN ParametersMain
ON ParametersMain2.VMV_CODE=ParametersMain.VMV_CODE
SET ParametersMain2.PARENT_VARIABLE_NAME=ParametersMain.PARENT_VARIABLE_NAME
AND ParametersMain2.VARIABLE_NAME=ParametersMain.VARIABLE_NAME;
Each time it says all the entries are being updated. each time i go look. the PARENT_VARIABLE_NAME fields and VARIABLE_NAME fields are still blank in ParametersMain2.
and the entire column of those fields are filled in in ParametersMain
why isntit working? i checked to see that its all the same data types and formats between the two tables.
Swap the AND with a comma, as below.
UPDATE
ParametersMain2
INNER JOIN
ParametersMain
ON ParametersMain2.VMV_CODE = ParametersMain.VMV_CODE
SET
ParametersMain2.PARENT_VARIABLE_NAME = ParametersMain.PARENT_VARIABLE_NAME ,
ParametersMain2.VARIABLE_NAME = ParametersMain.VARIABLE_NAME;
AND is operator that combines booleans (and nulls), if you want to set multiple fields separate them with a comma.