Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract data from SQL table 1

Status
Not open for further replies.

joeschoe

Programmer
Jan 13, 2002
67
IL
I am developing in VB6 and using MS SQL 2000 as the database engine.
My shipping SQL table has the following fields
1. ContainerReference
2. BoxSize
3. Product
4. BoxReference
For the query I want to know how many of each Box-Size is scheduled for a specific container.
Each box has a unique Reference
I have tried multiple variations of
Code:
    SumStr = "SELECT  count(BoxReference) AS totpersize " _
        & "FROM shipping  WHERE ContainerReference = '" & Con.text & "'" _
        & " GROUP BY BoxSize
        
    Set SumrS = connDB.Execute(SumStr, , adCmdText)

debug.print "ContainerReference: " & con.text

Do Until SumrS.EOF
   Debug.Print  SumrS.Fields(0).value, SumrS.Fields(1).Value
   SumrS.MoveNext
Loop
My problems:
1. I am not sure if I have the correct SQL SELECT syntax
2.How do I access the results of the query to create a textbox showing for example:
3. Can I use the "totpersize" to identify the quantity?
Code:
ContainerReference: Xo27354
Boxes     Count
===============
2x4       75
4x8       30
12x6     124
 
Try this:
Code:
SumStr = "SELECT  [blue]BoxSize[/blue], count(BoxReference) AS totpersize " _
        & "FROM shipping  WHERE ContainerReference = '" & Con.text & "'" _
        & " GROUP BY BoxSize

Yes, you can use "BoxSize" and "totpersize", or 0 and 1 to access the values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top