Oracleデータベースとワークシートからの照会を自動化するVBAを介してリコンシリエーションツールを構築しています。私がクエリを実行するとき、私はユーザに何のITEM(この場合はパイプライン)を問い合わせるか(ワークシートには多くの項目がある)と終了/開始日を入力させたい。私はトラブル次のことを考え出すを持っています:VBAの文字列から日付への変換とオートメーションプログラムのための古いSQLデータ出力のクリア
1)照会している - 返された値がNULLであれば、私はプリントアウトして、それを伝えることがどのように「DATAを使用できません」
2)どのように私は片付けることができますパイプラインAからの古いSQL文/データ出力、パイプラインBを照会していますか?
3)私の日付はOracleの文字列として保存されていますが、その日付をどのように変換できますか?
ありがとうございます!ここで
は、私がこれまで持っているものです。
またOption Explicit
Option Base 1
Dim cnnObject As ADODB.Connection
Dim rsObject As ADODB.Recordset
Dim strGPOTSConnectionString As String
Dim Pipeline As String
Dim DateStart As Date
Dim DateEnd As Date
Dim strQuery As String
Sub ClickButton2()
Debug.Print ("Button has been clicked")
Pipeline = InputBox("Enter PipeLine", "My Application", "Default Value")
DateStart = InputBox("Enter Start Date", "My Application", DateTime.Date)
DateEnd = InputBox("Enter End Date", "My Application", DateTime.Date + 1)
Range("B1").Value = Pipeline
Range("B2").Value = DateStart
Range("B3").Value = DateEnd
strQuery = "select pipelineflow.lciid lciid, ldate, volume, capacity, status, " & _
"pipeline, station, stationname, drn, state, county, owneroperator, companycode, " & _
"pointcode, pointtypeind, flowdirection, pointname, facilitytype, pointlocator, " & _
"pidgridcode from pipelineflow, pipelineproperties " & _
"where pipelineflow.lciid = pipelineproperties.lciid " & _
"and pipelineflow.audit_active = 1 " & _
"and pipelineproperties.audit_active =1 " & _
"and pipelineflow.ldate >= '" & Format(DateStart, "dd-MMM-yyyy") & "' and pipelineflow.ldate < '" & Format(DateEnd, "dd-MMM-yyyy") & "' " & _
"and pipelineproperties.pipeline = '" & Pipeline & "' "
Call PullZaiNetData(strQuery)
Call TieOut
End Sub
Sub PullZaiNetData2(ByVal strQry As String)
Set cnnObject = New ADODB.Connection
Set rsObject = New ADODB.Recordset
strGPOTSConnectionString = "DRIVER={Microsoft ODBC for Oracle}; SERVER=XYZ; PWD=XYZ; UID=XYZ"
cnnObject.Open strGPOTSConnectionString
rsObject.Open strQry, cnnObject, adOpenStatic
Worksheets("ZaiNet Data").Cells(1, 1).CopyFromRecordset rsObject
rsObject.Close
cnnObject.Close
Set rsObject = Nothing
Set cnnObject = Nothing
End Sub
Sub TieOut()
End Sub
私は、私が代わりに促されているのセルにユーザー入力の日付とパイプラインを聞かせてかもしれませんどのように、周りのものを変更したい場合は?
startDate = Worksheets("Instructions").Cells(5, 4).Value
これは可能でしょうか?