a guest Feb 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Dim datatype As Single
- datatype = DataTypeBox.Value
- Dim year As Single
- year = ForecastYearBox.Value
- Dim cnPubs As ADODB.Connection
- Set cnPubs = New ADODB.Connection
- Dim rsPubs As ADODB.Recordset
- Set rsPubs = New ADODB.Recordset
- cnPubs.Open strConn
- Set cmd = New ADODB.Command
- cmd.ActiveConnection = cnPubs
- cmd.CommandType = adCmdStoredProc
- cmd.CommandText = "CM.Proc_CashFlowForecast"
- cmd.CommandTimeout = 7200 'Seconds
- Call cmd.Execute(Parameters:=Array(year, datatype), Options:=adCmdStoredProc)
- With rsPubs
- ' Assign the Connection object.
- .ActiveConnection = cnPubs
- ' Extract the required records.
- .Open "SELECT * FROM AnalyticsV2.dbo.CashFlowForecast"
- ' Copy the records into cell A1 on Sheet1.
- If dataype = 12 Then
- Sheet1.Range("A2").CopyFromRecordset rsPubs
- ElseIf dataype = 3 Then
- Sheet2.Range("A2").CopyFromRecordset rsPubs
- End If
- End With
- Set rsPubs = Nothing
- Set cnPubs = Nothing
RAW Paste Data