PDA

View Full Version : Closing Excel & Opening Access



mundo7
11-06-2009, 05:01 AM
Hi,

I'm running a macro which opens an Access database and then i want it to save the Excel workbook and set the focus on the Access database i've just opened.

The code below is what i've got:

Sub PullData_Amend_2()
Set tk = ActiveWorkbook
Sheets("Download").Select
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
endRow = Range("A65536").End(xlUp).Row - 1
Range("F2").Resize(endRow, 1).FormulaR1C1 = "=RC[-1]&""_""&RC[5]"
Range("F2").Resize(endRow, 1).Copy
Range("F2").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
MsgBox "Data is now correctly formatted."
'open PQQ Database and close Excel
Set acApp = New Access.Application
acApp.Visible = True
acApp.OpenCurrentDatabase ("S:\XXXXX\Database.accdb")
tk.Save
tk.Close
End Sub


Now the problem is at the end, the macro opens the database ok, then makes it visible. It then saves the workbook and closes Excel - but also closes Access too.

How can i keep Access open at the end??

Many thanks

James

mdmackillop
11-06-2009, 06:40 AM
Try using FollowHyperlink to open the database.