PDA

View Full Version : VBA from access to excel



Charlotte
07-02-2019, 03:57 AM
Hi I am trying to pull data from access database through vba on excel.

sql = "" & _
"SELECT MainLog.WeekNumber, MainLog.Created, MainLog.Number, MainLog.Category, MainLog.HostDistributionCentre, MainLog.DeliveryType, MainLog.OrderNumber, MainLog.Affected" & _
"FROM MainLog " & _
"WHERE (MainLog.Number) Like 'SLA%'" & _
"AND FinYear = (SELECT MAX(FinYear) FROM MainLog)AND Created = " & chosenDate & " ;"

I understand sql and vba have different terminology - does this look correct?

Bob Phillips
07-02-2019, 07:34 AM
It looks okay, but impossible to guarantee without knowing anything about the database, but you will need to set up a connection and invoke the query.

You do not need the "" & _ at the start.