Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What is the VBA to close an external database after appending to it and then compact it?

Posted on 2009-04-01
3
Medium Priority
?
411 Views
Last Modified: 2012-05-06
What is the VBA to close an external database after appending to it and then compact it?
0
Comment
Question by:indyng
  • 2
2 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24038839
how are you appending to it? and I assume you are programmatically compacting it?
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24038882
we could post a message to it saying to close it

if you set a title to your msaccess window (Tools/Startup), you can try find it and send a close message

eg add this lot to a module


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_CLOSE = &H10

Public Sub FindAndCloseApp()

    Dim lHandle As Long

'Find a window called Fred    
    lHandle = FindWindow(vbNullString, "Fred")
   
   
    If lHandle > 0 Then
        PostMessage lHandle, WM_CLOSE, 0&, 0&
    End If

End Sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question