Solved

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

Posted on 2009-04-01
3
394 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
3 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 500 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now