?
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
?
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

762 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