0

I am trying to merge data from several tables in several MS Access databases. All the tables have the same structure. I found this script online and, visually, it seems to do exactly what I want it to do.

Parent.Folder <- "D:/Documents/Rwd"
subfolders <- list.dirs(Parent.Folder, recursive = TRUE)[-1]

list_filenames <- list.files(subfolders, full.names = TRUE, recursive = FALSE)
acc_files <- list_filenames[grep(".mdb|.accdb", list_filenames)]

output <- lapply(acc_files, 
                 function(file) {
                    channel <- odbcConnectAccess(file) 
                    # ALTERNATIVE CONNECTION
                    # channel <- odbcDriverConnect(paste0('driver=
                    #            {Microsoft Access Driver (*.mdb, *.accdb)};
                    #            DBQ=', file))                        
                    data <- sqlQuery(channel, "select * from HRESULTS")
                    close(channel)
                    return(data) 
                })

data <- do.call(rbind, output)

The thing is, it gives me an error.

Error in odbcConnectAccess(file) : 
  odbcConnectAccess is only usable with 32-bit Windows

I started R in 32-bit mode and it throws the error described above.

Any idea what could be wrong? I googled it, and didn't find anything useful.

  • 1
    I'm not familiar with this process, but the error reads (to me) as you need to be using a 32 bit version of windows OS. See the following [SO post](http://stackoverflow.com/questions/13070706/how-to-connect-r-with-access-database-in-64-bit-window). – lmo May 14 '16 at 11:31
  • Yes! Right! I have Windows 7, 64-bit. But, how do I get around this issue? I can't switch to a different machine. There must be some kind of work-around. – Ryan Shuell May 14 '16 at 11:34
  • Read the post and try the stuff there that are 64 bit related. – lmo May 14 '16 at 11:43
  • Try using `odbcConnectAccess2007()` instead of `odbcConnectAccess()`. – Gord Thompson May 14 '16 at 11:46
  • Thanks Gord. That's a great suggestion. Unfortunately, it didn't work. Now, I get this: Error in sqlQuery(channel, "select * from Products") : first argument is not an open RODBC channel In addition: Warning messages: 1: In odbcDriverConnect(con, ...) : [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 2: In odbcDriverConnect(con, ...) : ODBC connection failed – Ryan Shuell May 14 '16 at 11:57

0 Answers0