Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good Afternoon,
This is my first post and I hope that I came to the right place. I have scoured the web for answers, but it seems to no avail. I have an Access database set up to do simple select query to pull information from various sources using the Choose function - basically the sources the data is pulled from depends on an index number assigned to every record based on various logical statements that examine certain input fields associated with each record member. That part aside, the query works exactly as I need it to and if I run it from Access and simply copy the data over to Excel, no problem. Automation is the name of the game however, and I would like to import the query via the press of a button from the Excel file, eliminating the need to open the .mdb at all. Here is where I run into problems. This is the query SQL code being used: SELECT DISTINCT [O:\Fomi\Out\Paymin].CUSIP, Choose(qBBRaw!Index,Null,qBBGold!NXT_REFIX_DT,qBBG old!NXT_REFIX_DT,qBBGold!NXT_CPN_DT,qBBGold!NXT_CP N_DT,qBBGold!NXT_CPN_DT,qBBRaw!MTG_NXT_PAY_DT_SET_ DT,qBBRaw!MTG_NXT_PAY_DT_SET_DT,qBBRaw!MTG_NXT_PAY _DT_SET_DT,qBBGold!PREV_CPN_DT) AS [BB Eff Mat Date], Choose(qBBRaw!Index,Null,qBBGold!LAST_REFIX_DT,qBB Gold!LAST_REFIX_DT,qBBGold!PREV_CPN_DT,qBBGold!PRE V_CPN_DT,qBBGold!PREV_CPN_DT,qBBRaw!MTG_ACC_RT_STA RT_DT,qBBRaw!MTG_ACC_RT_START_DT,qBBRaw!MTG_ACC_RT _START_DT,qBBRaw!MTG_FACT_SET_DT_STRT_NEXT_ACC_DT) AS [BB Ex Date], Choose(qBBRaw!Index,Null,qBBGold!NXT_CPN_DT,qBBGol d!NXT_CPN_DT,qBBGold!NXT_CPN_DT,qBBGold!NXT_CPN_DT ,qBBGold!NXT_CPN_DT,qBBRaw!MTG_NXT_PAY_DT_SET_DT,q BBRaw!MTG_FACT_SET_DT_STRT_NEXT_ACC_DT,qBBRaw!MTG_ FACT_SET_DT_STRT_NEXT_ACC_DT,qBBRaw!MTG_START_ACC_ DT) AS [BB Pay Date], Choose(qBBRaw!Index,Null,qBBRaw!CPN,qBBGold!CUR_CP N,qBBRaw!CPN,qBBRaw!CPN,qBBRaw!CPN,qBBRaw!CPN,qBBR aw!CPN,qBBRaw!CPN,qBBRaw!CPN) AS [BB CPN] FROM (qBBGold INNER JOIN [O:\Fomi\Out\Paymin] ON qBBGold.CUSIP = [O:\Fomi\Out\Paymin].CUSIP) INNER JOIN qBBRaw ON [O:\Fomi\Out\Paymin].CUSIP = qBBRaw.CUSIP; I've tried two methods for the Excel VBA import coding. One is storing the above in a string variable (QueryString) and just running: With ..QueryTables.Add(Connection:=Array("OLEDB;Provide r=Microsoft.Jet.OLEDB.4.0;" _ , "Password="""";User ID=Admin;" _ , "Data Source=S:\BBShare\Corp Floater Update\Corp Floater.mdb;" _ , "**various other options**, Destination:=ActiveSheet.Cells(1, 1)) .CommandType = xlCmdSql .CommandText = QueryString End With I've also tried running it by directly refrencing the Query name without entering the SQL code: .CommandType = xlCmdTable .CommandText = Array("*Query Name*") Both have the same problem with the outcome. That problem is as such. If you look at the SQL query string, I have 4 fields using the Choose function. No matter what I do, the first 3 fields do NOT import, but the last one DOES. As you may notice, the first three contain date data, where as the last one is a number field. These formats are NOT specified in the select query explicitly. They ARE specified explicitly in the source data table specs that are used to link to the Access Database. Any help would be greatly appreciated. If something is unclear or there is some other information you guys need, please let me know and I'll try to post as much as possible. Running Office 2003 SP3. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem importing from access | Excel Discussion (Misc queries) | |||
Problem importing Excel to Access | Excel Worksheet Functions | |||
Importing a CSV file, would like to skip first row in Excel | Excel Discussion (Misc queries) | |||
Problem importing data from Access | Excel Discussion (Misc queries) | |||
problem with importing data from access to excel | Excel Programming |