Private Sub Text5_Change()
Dim ccs As Double
Dim bal As Double
Dim loss As Double
Dim pcs As Double
Dim bcs As Double
Dim bgl, aa As Double
Dim total As Double
Dim a As Long
Dim X, y, z As Integer
X = 0
z = 0
a = 0
aa = IIf(Text9.Text = "", 0, Text9.Text)
pcs = IIf(Text4.Text = "", 0, Text4.Text)
ccs = IIf(txtCase.Text = "", 0, txtCase.Text)
ctax = 0
Set Rs = New ADODB.Recordset
Set conn = New ADODB.Connection
conn.Open "DSN=BIRREM2"
Rs.Open "SELECT * from tblproducts where pcode='" & Trim(Text5.Text) & "'", conn, adOpenStatic, adLockOptimistic
If Not Rs.EOF Then
Text6.Text = Format(Rs!Cap_Liters, "###,###,###.00")
bal = Format(ccs * Rs!Cap_Liters, "###,###,###.00")
Text7.Text = Format(bal, "###,###,###.00")
Text11.Text = Format(pcs * Rs!Cap_Liters, "###,###,###.00")
'Text15.Text = Format(aa * Rs!Cap_Liters, "###,###,###.00")
'---------
Dim rsb As New ADODB.Recordset
dataconnection
rsb.Open "select prod_gl from tIceDetails where manu_date='" & CDate(txtmanufacture_date.Text) & "'", conn, adOpenStatic, adLockOptimistic
While Not rsb.EOF
a = rsb!prod_gl
rsb.MoveNext
Wend
rsb.Close
a = (Round((a * 1.018), 3)) - a
Text8.Text = a
'---------
Dim rsa As New ADODB.Recordset
dataconnection
rsa.Open "select bal_cs from tIceDetails where manu_date='" & CDate(txtmanufacture_date.Text) - 1 & "'", conn, adOpenStatic, adLockOptimistic
While Not rsa.EOF
X = rsa!bal_cs
rsa.MoveNext
Wend
rsa.Close
'---------
rsa.Open "select prod_cs, rem_cs from tIceDetails where manu_date='" & CDate(txtmanufacture_date.Text) & "'", conn, adOpenStatic, adLockOptimistic
While Not rsa.EOF
pcs = rsa!prod_cs
ccs = rsa!rem_cs
rsa.MoveNext
Wend
rsa.Close
aa = Format(Val(X) + Val(pcs) - Val(ccs), "###,###,###.00")
Text9.Text = Format(aa, "###,###,###.00")
'-----
Dim rsc As New ADODB.Recordset
dataconnection
rsc.Open "select Cap_Liters,TAX from tblproducts where pcode='" & Trim(Text5.Text) & "'", conn, adOpenStatic, adLockOptimistic
While Not rsc.EOF
total = Format(aa * rsc!Cap_Liters, "###,###,###.00")
bgl = Format(total / rsc!tax, "###,###,###.00")
rsc.MoveNext
Wend
rsc.Close
Text15.Text = Format(total, "###,###,###.00")
Text17.Text = bgl
Set conn = Nothing
Set Rs = Nothing
Set rsa = Nothing
Set rsb = Nothing
Set rsc = Nothing
End If
End Sub
----------------
Public Sub load_data()
Set conn = New ADODB.Connection
Set Rs = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & App.Path & "\otr.mdb"
Rs.Open "SELECT prod_cs,prod_gl,rem_cs,rem_gl,losses,bal_cs,bal_gl,pl FROM tIceDetails where manu_date like '" & CDate(txtmanufacture_date.Text) & "'", conn, adOpenStatic, adLockOptimistic
'Rs.Open "SELECT * FROM tIceDetails where manu_date like '" & CDate(txtmanufacture_date.Text) & "'", conn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = Nothing
Set DataGrid1.DataSource = Rs
With DataGrid1
' .ClearFields
'.ReBind
.Columns(0).Width = 800
.Columns(0).Alignment = 2
.Columns(0).Caption = "Prod CS"
.Columns(1).Width = 1000
.Columns(1).Alignment = 2
.Columns(1).Caption = "Prod GL"
.Columns(1).NumberFormat = "###,###,###.00"
.Columns(2).Width = 800
.Columns(2).Alignment = 0
.Columns(2).Caption = "Cases"
.Columns(3).Width = 1300
.Columns(3).Alignment = 1
.Columns(3).Caption = "Total Liters"
.Columns(3).NumberFormat = "###,###,###.00"
.Columns(4).Width = 800
.Columns(4).Alignment = 2
.Columns(4).Caption = "Losses"
.Columns(4).NumberFormat = "###,###,###.00"
.Columns(5).Width = 800
.Columns(5).Alignment = 0
.Columns(5).Caption = "Balance CS"
.Columns(6).Width = 1300
.Columns(6).Alignment = 1
.Columns(6).Caption = "Balance GL"
.Columns(6).NumberFormat = "###,###,###.00"
.Columns(7).Width = 1300
.Columns(7).Alignment = 2
.Columns(7).Caption = "PL"
.Columns(7).NumberFormat = "###,###,###.00"
End With
Set Rs = Nothing
Set conn = Nothing
End Sub