sirhannick
Registered User.
- Local time
- Today, 15:52
- Joined
- Jun 18, 2013
- Messages
- 20
Hello. I am working with an Oracle database which I have linked to in access using the ODBC drivers. I have an excel sheet which is currently working to dump the data needed. Here is the critical part of the code in the excel sheet that I have:
I would like to create a similar query in Access which would be easy to work with. It's a requirement to use Access and not Excel because I already have a rather complicated Access front end going. Any help would be greatly appreciated.
I currently have the 3 different tables imported as linked tables and can get a query to output some data, but it does not match what I am getting in excel in the least bit. I am not sure how critical the relationships of the tables in access is versus what the actual SQL in the query is. Thanks again.
Code:
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DRIVER={Oracle in instantclient_11_2};SERVER=server;UID=uid;PWD=pwd;DBQ=dbq;DBA=dba;" _
), Array( _
"APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BNF=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=Me;CSR=F;" _
), Array("FWC=F;FBS=60000;TLO=O;MLD=0;ODA=F;")), Destination:=Range("$A$1")). _
QueryTable
.CommandText = Array( _
"SELECT AL1.PRP_BEZ, AL1.PRP_VAR, AL1.PRP_VER, AL1.RUN_DATE, AL1.RUNID, AL3.MRK_NUM_EXT, AL3.MRK_BEZ, AL3.MRK_WERT, " _
, _
"AL3.MRK_EINHEIT, AL3.MRK_EIN_GUT, AL2.MRK_TXT, AL1.BMT_NAME,AL1.SFT_NAME, AL1.SFT_VERSION, AL1.SFT_TYP FROM EVAPROD.V_PD_LFD_RUN AL1, EVAPROD.V_PD_LFD_MXT2 AL" _
, _
"2, EVAPROD.V_PD_LFD_MED2 AL3 WHERE ( AL3.RUNID = AL2.RUNID (+) AND AL3.RUNID_TYPE = AL2.RUNID_TYPE (+) AND AL3.RU" _
, _
"N_DATE = AL2.RUN_DATE (+) AND AL1.PRP_VAR = '" & Test & "' AND AL3.MRK_NUM = AL2.MRK_NUM (+) AND AL3.RUNID=AL1.RUNID AND AL3.RUNID_TYPE=AL1.RUNID_T" _
, _
"YPE AND AL1.PRP_BEZ = '" & Product & "' AND AL3.RUN_DATE=AL1.RUN_DATE) AND ( AL1.RUN_DATE>={ts '" & Date1 & "'} AN" _
, "D ( AL1.RUN_DATE<={ts '" & Date2 & "'}) AND rownum < 500000)")
I currently have the 3 different tables imported as linked tables and can get a query to output some data, but it does not match what I am getting in excel in the least bit. I am not sure how critical the relationships of the tables in access is versus what the actual SQL in the query is. Thanks again.