472,351 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

select *, count(group), sum(number)

2
Hi everyone!
I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore.
I'm working with an AS400 and I mhave to do an "interface" in Access. It's like a little system to make a production plan. It must get information about part numbers, description, set where the part number belongs, quantity of part numbers that the set uses, stock number(this is a text value, it could be "re", "co", "pt", etc but I just use "co" and "re"), stock and production group.
To connect Access to the server I vinculated three tables: teils, strus and lgbs. To make things faster, I created a query and then used create tbale query to make a new table. Then did a form and added new fields on that table: daily use, prod. days, stock on hand and period days.
I did a form and it works right. But my problem is from the first query:
SELECT DISTINCT RHDBD_16_STRUS.STFIRM, RHDBD_16_STRUS.STKOMP, RHDBD_16_TEILS.TEBEZ1, RHDBD_16_STRUS.STBGNR, RHDBD_16_LGBS.LSLANR, RHDBD_16_TEILS.TEMAGR, RHDBD_16_LGBS.LSLGBE INTO PLANEACION
FROM RHDBD_16_LGBS, RHDBD_16_STRUS, RHDBD_16_TEILS
WHERE (((RHDBD_16_STRUS.STFIRM)="5") And ((RHDBD_16_STRUS.STKOMP)=(RHDBD_16_TEILS.TETENR) And (RHDBD_16_STRUS.STKOMP)=(RHDBD_16_LGBS.LSTENR)) And ((RHDBD_16_STRUS.STBGNR) Not Like "ES*" And (RHDBD_16_STRUS.STBGNR) Not Like "MS*") And ((RHDBD_16_LGBS.LSLANR)="RE") Or (RHDBD_16_LGBS.LSLANR)="CO") And ((RHDBD_16_TEILS.TEMAGR)="ASOX")
ORDER BY RHDBD_16_STRUS.STBGNR;
This one is from the vinculated tables, and I want to get in the same query one to get the count of part numbers by set. This is the query that does it:
select count(RHDBD_16_STRUS.STKOMP) group by RHDBD_16_STRUS.STBGNR.

I couldn't find the way to do it, so I used a code like this:
strPalabrasegunda = STBGNR
Set prueBa = DBEngine.OpenDatabase("C:\Documents and Settings\mzarate\
Mis documentos\PRUEBA\PLANEACION_DE_LA_PRODUCCION_PEM. mdb")
strSQL = "SELECT * FROM PLANEACION where PLANEACION.STBGNR like '*" & strPalabrasegunda & "*'"
Set taBla = prueBa.OpenRecordset(strSQL, dbOpenDynaset)
With taBla
.MoveLast
.MoveFirst 'Voy al primer y al último registros con el objetivo de contar los registros.
cuentapalabra = taBla.RecordCount
Texto26 = cuentapalabra

That does it fast, no problem if it keeps so.
But there's another problem, the fields "set" and "part number" could be the same in several entries (does it mean "registro"). I mean, the same combination part number-set could be in many entries. So, it could be fixed with a select distinct, but the fields stock number or stock make it change. I know it's the same but I can't find a way to show it once.
Now I'm trying to use a sum, but I'm having problems again:
SELECT Sum(PLANEACION.LSLGBE) AS SumaDeLSLGBE
FROM PLANEACION
GROUP BY PLANEACION.STBGNR;
This makes it, but the same problem: how do I get it in an only query or how do I use it for VB. Well, actually I have it in VB, but I don't know the way o show the result from the sql statement in a textbox.
As you can see I'm not fine and maybe I'm not in the right way, so if you can help me to get the three queries in one or to get the resulta from my query to a textbox.
Thanks for the time and I hope you have understood -because the trouble is a little confussing and my English is not good enouh-, if you didn't, please write to this e-mail:
**Email removed as per site rules**
Thank you again and have a nice -amazing- day!
Jun 29 '07 #1
1 3526
NeoPa
32,511 Expert Mod 16PB
I'm sorry to have to say this, but your question is too long and complicated to understand.
I appreciate that you made a great deal of effort to explain yourself, but the simple fact is, that something this long and complex is hard enough to understand (don't forget we can't see what you're talking about) when written in clear English (which even English people rarely manage well). When words are missed out or misspelled it is just too difficult to understand. I'm sorry, and I'm not trying to be at all critical. You've made a good attempt, but it's simply too hard to understand.

MODERATOR.
Jul 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Willem-Jan Selen | last post by:
Hie everybody, I have a problem with the following, I have a table with a row containing numbers with 2 decimal places. I want to count the...
2
by: Chris | last post by:
Hello all, I'm having some trouble setting up a query. Background: The table TBLSCREEN stores data about screenings of patients/subjects for...
2
by: Peter Bailey | last post by:
I have a query that creates a graph of bookings from the course start date looking back 20 weeks based on a running sum. I also have a query that...
2
by: tedhekman | last post by:
Hi there! I am pretty new to Access, have been loving learning it! I have a problem here I can't even begin to figure out. Here is what I need:...
3
by: lagj | last post by:
Using MySQL 5.0.15 I am no expert so maybe I am deeply misundertanding how this should work. I have a relatively complex quey with joins and a...
3
by: JDiamond | last post by:
Hi, I have a table called Hosts. The Hosts table contains the following fields: Each field represents a step in the project. The tech...
2
by: trihanhcie | last post by:
Hi, Well the following query is not the one i will use but it's the same prob : SELECT sum(country_id ) , count( country_id ) FROM...
10
by: Rudolf Bargholz | last post by:
Perhaps some kind soul could help me out with an SQL I have been trying all day to get to work, where one colum is just not summing up the way I...
1
by: godfather96 | last post by:
I am using a web control called eXml which is an extention to ms xml web control which supports xslt 2.0 when trying to group elements i receive...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.