How to refresh the table list using vba in Access 2007
.
I make table in Sql
code using vba
:
DoCmd.RunSQL "SELECT * INTO table2 FROM table1", True
RefreshDatabaseWindow
DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\import.mdb", , "table2", tab2, 0
Error message: Microsoft Office Access can not find the object table2
if pause RefreshDatabaseWindow
and refresh manualy press F5
and run back to work correctly. How to do it automatically? In Access 2003 work correctly if table list is active.
I try pause but not work:
Private Declare Sub sApiSleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
...
RefreshDatabaseWindow
Call sApiSleep(4000)
...
Works in Access 2007, 2010
(project .ADP
):
RefreshDatabaseWindow
DoCmd.SelectObject acTable, "table2", True
DoCmd.TransferDatabase ...