ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import query from access into excel via vba, but will not refresh (https://www.excelbanter.com/excel-programming/410433-import-query-access-into-excel-via-vba-but-will-not-refresh.html)

newyears

Import query from access into excel via vba, but will not refresh
 
Hello,

I wrote an excel program to run a macro in access, then import query results
into excel sheet. My problem is that when I run my excel program each day, I
get a new set of query data, which gets imported via my code, but the data is
not changed from the day before. When I view the query results in access, the
new data is present, so I'm not sure why it is not getting imported. It's
like the old data keeps getting pasted, but I do not know why. I appreciate
any help. I've turning on the refresh function for importing, but it doesn't
do the trick. The following is my code in excel.

Private Sub obtaincmmsdata_Click()
Dim obtaincmmsdata As String
Dim AC As Object
Set AC = CreateObject("access.application")
AC.Visible = False

AC.opencurrentdatabase (Filename)
With AC
.DoCmd.RunMacro "FORD WEEKLY BTS REPORT OUT"
.Quit
End With
Sheets("Actual").Select
Range("E2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False

End Sub




All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com