'connection details of MS SQL 2005
Public Con As ADODB.Connection
Public Rst As ADODB.Recordset
Public Com As ADODB.Command
Set Con = New ADODB.Connection
Set Com = New ADODB.Command
Set Rst = New ADODB.Recordset
'----------
'connection details of MS Access
Dim PrntCon As ADODB.Connection
Dim PrntRst As ADODB.Recordset
Dim PrntCom As ADODB.Command
Set PrntCon = New ADODB.Connection
Set PrntRst = New ADODB.Recordset
Set PrntCom = New ADODB.Command
'----------
Dim i As Integer
Dim ConStr As String
'Start data retreive
ConStr = "Provider=MSDASQL.1;Password=pwd;Persist Security Info=True;User ID=usr;Data Source=MyODBC"
MsFlxGrd.Clear
MsFlxGrd.Rows = 0
Rst.open "SELECT TT_DATE,SUM(LC_TOT_AMT) as LcAmt FROM TT WHERE IS_EZRMT = 1 AND TT_DATE >= '" & FrmDate & "' AND TT_DATE <= '" & ToDate & "' AND USR_ID = " & Me.TxtUid.Text & " AND CNCL <> 1 GROUP BY TT_DATE", Con, adOpenKeyset
If Rst.RecordCount > 0 Then
If IsNull(Rst.Fields!LcAmt) = False Then
CurRow = MsFlxGrd.Rows
MsFlxGrd.Rows = MsFlxGrd.Rows + Rst.RecordCount
FMain.pbMain.Visible = True
FMain.pbMain.Max = MsFlxGrd.Rows
For i = CurRow To MsFlxGrd.Rows - 1
MsFlxGrd.TextMatrix(i, 0) = "EzRemit"
MsFlxGrd.TextMatrix(i, 1) = Format(Rst.Fields!TT_DATE, "dd/mm/yyyy")
MsFlxGrd.TextMatrix(i, 2) = "1"
MsFlxGrd.TextMatrix(i, 3) = Rst.Fields!LcAmt
MsFlxGrd.TextMatrix(i, 4) = "0"
Rst.MoveNext
FMain.pbMain.Value = i
Next i
FMain.pbMain.Value = MsFlxGrd.Rows
FMain.pbMain.Visible = False
End If
End If
Rst.Close
Rst.open "select * from InnerTrns where Tr_Date >= '" & FrmDate & "' AND Tr_Date <= '" & ToDate & "' AND ToUsrID = " & Me.TxtUid.Text, Con, adOpenKeyset
If Rst.RecordCount > 0 Then
CurRow = MsFlxGrd.Rows
MsFlxGrd.Rows = MsFlxGrd.Rows + Rst.RecordCount
FMain.pbMain.Visible = True
FMain.pbMain.Max = MsFlxGrd.Rows
For i = CurRow To MsFlxGrd.Rows - 1
MsFlxGrd.TextMatrix(i, 0) = "Transfer [" & Trim$(Rst.Fields!FrmUsr) & " >> " & Trim$(Rst.Fields!ToUsr) & "]"
MsFlxGrd.TextMatrix(i, 1) = Format(Rst.Fields!Tr_Date, "dd/mm/yyyy")
MsFlxGrd.TextMatrix(i, 2) = "1"
MsFlxGrd.TextMatrix(i, 3) = Rst.Fields!Tr_Amt
MsFlxGrd.TextMatrix(i, 4) = "0"
Rst.MoveNext
FMain.pbMain.Value = i
Next i
FMain.pbMain.Value = MsFlxGrd.Rows
FMain.pbMain.Visible = False
End If
Rst.Close
Rst.open "select * from InnerTrns where Tr_Date >= '" & FrmDate & "' AND Tr_Date <= '" & ToDate & "' AND FrmUsrID = " & Me.TxtUid.Text, Con, adOpenKeyset
If Rst.RecordCount > 0 Then
CurRow = MsFlxGrd.Rows
MsFlxGrd.Rows = MsFlxGrd.Rows + Rst.RecordCount
FMain.pbMain.Visible = True
FMain.pbMain.Max = MsFlxGrd.Rows
For i = CurRow To MsFlxGrd.Rows - 1
MsFlxGrd.TextMatrix(i, 0) = "Transfer [" & Trim$(Rst.Fields!FrmUsr) & " >> " & Trim$(Rst.Fields!ToUsr) & "]"
MsFlxGrd.TextMatrix(i, 1) = Format(Rst.Fields!Tr_Date, "dd/mm/yyyy")
MsFlxGrd.TextMatrix(i, 2) = "2"
MsFlxGrd.TextMatrix(i, 3) = "0"
MsFlxGrd.TextMatrix(i, 4) = Rst.Fields!Tr_Amt
Rst.MoveNext
FMain.pbMain.Value = i
Next i
FMain.pbMain.Value = MsFlxGrd.Rows
FMain.pbMain.Visible = False
End If
Rst.Close
Rst.open "SELECT PV_No, PV_Date, AMT ,PV_Type FROM EzPymnt WHERE PV_DATE >= '" & FrmDate & "' AND PV_DATE <= '" & ToDate & "' AND DEPT_ID = " & Trim(TxtUid.Text), Con, adOpenKeyset
If Rst.RecordCount > 0 Then
CurRow = MsFlxGrd.Rows
MsFlxGrd.Rows = MsFlxGrd.Rows + Rst.RecordCount
FMain.pbMain.Visible = True
FMain.pbMain.Max = MsFlxGrd.Rows
For i = CurRow To MsFlxGrd.Rows - 1
MsFlxGrd.TextMatrix(i, 0) = "PV" & Rst.Fields!PV_NO & " (" & Rst.Fields!PV_Type & ")"
MsFlxGrd.TextMatrix(i, 1) = Format(Rst.Fields!PV_DATE, "dd/mm/yyyy")
MsFlxGrd.TextMatrix(i, 2) = "2"
MsFlxGrd.TextMatrix(i, 3) = "0"
MsFlxGrd.TextMatrix(i, 4) = Rst.Fields!Amt
Rst.MoveNext
FMain.pbMain.Value = i
Next i
FMain.pbMain.Value = MsFlxGrd.Rows
FMain.pbMain.Visible = False
End If
Rst.Close
Rst.open "select C_Name, C_State, C_Cntry from EzRegistr", Con, adOpenKeyset
CName = Rst.Fields!C_name
Rst.Close
Rst.open "select * from EzAgBrnch where BrName = '" & UsrBrnch & "'", Con, adOpenKeyset
CAdd = Rst.Fields!BrAdd1 & ", " & Rst.Fields!BrAdd2 & ", " & Rst.Fields!BrTel
Con.Close
'end retreive
'Start insert to local MS Access
PrntCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Reports\Ez_rpt.mdb;Persist Security Info=False"
PrntCon.open
PrntCom.ActiveConnection = PrntCon
PrntCom.CommandText = "delete from LCStckRpt"
PrntCom.Execute
For i = 0 To MsFlxGrd.Rows - 1
PrntCom.CommandText = "insert into EzLCStckUnSort values ('" & Me.MsFlxGrd.TextMatrix(i, 0) & "','" & Me.MsFlxGrd.TextMatrix(i, 1) & "'," & Me.MsFlxGrd.TextMatrix(i, 2) & "," & Me.MsFlxGrd.TextMatrix(i, 3) & "," & Me.MsFlxGrd.TextMatrix(i, 4) & ")"
PrntCom.Execute
FMain.pbMain.Value = i
Next i
Set PrntCon = Nothing
Set PrntCom = Nothing
Dim CrystApp As CRAXDRT.Application
Dim CrystRpt As CRAXDRT.Report
Dim MyFrmDtlRpt As New FrmRptViewr
Set CrystApp = New CRAXDRT.Application
Set CrystRpt = CrystApp.OpenReport(App.Path & "\Reports\LCBalanceRpt.rpt")
CrystRpt.DiscardSavedData
CrystRpt.ParameterFields.GetItemByName("FrmDate").AddCurrentValue (FrmDate)
CrystRpt.ParameterFields.GetItemByName("ToDate").AddCurrentValue (ToDate)
CrystRpt.ParameterFields.GetItemByName("User").AddCurrentValue (CmbUser.Text)
CrystRpt.ParameterFields.GetItemByName("CName").AddCurrentValue (CName)
CrystRpt.ParameterFields.GetItemByName("CAdd").AddCurrentValue (CAdd)
MyFrmDtlRpt.CRViewer91.ReportSource = CrystRpt
MyFrmDtlRpt.CRViewer91.Refresh
MyFrmDtlRpt.CRViewer91.ViewReport
Do While MyFrmDtlRpt.CRViewer91.IsBusy
DoEvents
Loop
MyFrmDtlRpt.CRViewer91.Zoom 100
MyFrmDtlRpt.Caption = MyFrmDtlRpt.Caption & " (" & Me.Caption & ")"
MyFrmDtlRpt.Show
Set CrystApp = Nothing
Set CrystRpt = Nothing