[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/09/2009 at 08:26PM PDT, ID: 24638913
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Get the total

Asked by ERWIIN in Visual Basic v1.0.5.x, Microsoft Visual Basic.Net, VB Script

Tags: vb6

How can I get the total of Quantity in My Data and display it to tdbGrid?
My problem is  like this;
In my table Stock are as follows;
Procode      Proname        Quantity        Menu_code
134              Pork-Pata       200                    80
135              Pork-Sig         -50                     80
136              Pork-San        75                      80
137              Pork-Bag        25                      80
I want to get the total of Quantity and display it to tdbGrid
I'm using the code below but it only display in single line..
My bases is that the menu_code, since they are the same.
Do I need to change the code? Or the code is not applicable on this scenario?
What shall I do?
Please help thanks!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
'Form1
Public cn As ADODB.Connection
Dim x As XArrayDB
 
Sub Load(lpORDOCNO As String)
Dim s As dbAccess
Dim rs As ADODB.Recordset
Dim i As Long, BALANCE As Double
Set s = New dbAccess
s.OPEN_CON "Mydb", "Winpos"
Set rs = s.Get_Stock(lpORDOCNO)
INITG
With rs
     If .BOF = True And .EOF = True Then
     Else
        i = 0
        .MoveLast
        x.ReDim 0, .RecordCount, 0, 3
        .MoveFirst
        Do While Not .EOF
                x(i, 0) = CStr(!ProCode)
                x(i, 1) = CStr(!Proname)
                x(i, 2) = QTYONHAND(CStr(!Menu_Code), s)
                If IsNull(!um) Then
                    x(i, 3) = ""
                Else
                    x(i, 3) = Trim(!um)
                End If
                i = i + 1
            .MoveNext
        Loop
        x.DeleteRows i
     End If
End With
Set rs = Nothing
Set s = Nothing
tg.Array = x
tg.ReBind
End Sub
 
Private Sub Command1_Click()
Load "B" & txtinvoiceno.Text
End Sub
Private Sub Form_Load()
INITG
End Sub
Private Sub INITG()
Dim MAXROW As Long, MAXCOL As Long
Set x = New XArrayDB
x.ReDim 0, 0, 0, 4
    For MAXROW = x.LowerBound(1) To x.UpperBound(1)
        For MAXCOL = x.LowerBound(2) To x.UpperBound(2)
            x(MAXROW, MAXCOL) = " "
        Next MAXCOL
    Next MAXROW
With tg
        .Close
        .Columns(3).Locked = True
        .Columns(4).Locked = True
        .Columns(1).AutoDropDown = True
        .Array = x
End With
End Sub
 
Private Function QTYONHAND(M_code As String, x As dbAccess) As Double
    Dim rs As ADODB.Recordset
    Set rs = x.GET_QUANTITY_ON_HAND(M_code)
    With rs
        If .BOF = True And .EOF = True Then
            QTYONHAND = 0
        Else
            QTYONHAND = !QUANTITY
        End If
        .Close
    End With
    Set rs = Nothing
End Function
 
' Class Modules
 
Option Explicit
Public cn As ADODB.Connection
Public Sub OPEN_CON(db As String, ServerName As String)
Set cn = New ADODB.Connection
cn.Provider = "sqloledb"
cn.ConnectionTimeout = 25
cn.Properties("Data source").Value = Trim(ServerName)
cn.Properties("Initial Catalog").Value = db
cn.Properties("User ID").Value = "sa"
cn.Properties("Password").Value = ""
cn.CursorLocation = adUseClient
cn.Open
 
End Sub
 
Public Function GET_QUANTITY_ON_HAND(lpCode As String) As ADODB.Recordset
Dim strSQL As String
Dim rs As ADODB.Recordset
strSQL = "select quantity from stock where Menu_Code='" & lpCode & "'"
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = cn
rs.CursorLocation = adUseClient
rs.LockType = adLockReadOnly
rs.CursorType = adOpenForwardOnly
rs.Open strSQL
Set rs.ActiveConnection = Nothing
Set GET_QUANTITY_ON_HAND = rs
Set rs = Nothing
End Function
[+][-]08/09/09 09:14 PM, ID: 25057141

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/10/09 02:57 AM, ID: 25058384

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic v1.0.5.x, Microsoft Visual Basic.Net, VB Script
Tags: vb6
Sign Up Now!
Solution Provided By: emoreau
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08/10/09 03:00 AM, ID: 25058392

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625