Clearing the Immediate Window

aziz rasul

Active member
Local time
Today, 11:35
Joined
Jun 26, 2000
Messages
1,935
Is their a way of Clearing the Immediate Window using code?
 
I placed the code in a new module and ran it, but it only cleared the new code instead of clearing the immediate window contents.
 
Hi -
Code:
Public Sub MeGo()
'*******************************************
'purpose:   Erase contents of debug (immediate) window
'coded by:  raskew
'inputs:    from debug window:  mego <enter>
'*******************************************

Dim strErase As String

   strErase = String(256, Chr(13) + Chr(10))
   Debug.Print strErase

End Sub

...another one along these lines is closing all open modules, forms, etc., after doing a Find operation:
Code:
Public Sub CloseModules()
'*******************************************
'Purpose:   Close all open modules, forms
'           and reports.  Useful after
'           performing a search within
'           modules.
'Coded by:  raskew
'Inputs:    from debug window:  call closemodules
'*******************************************

Dim db      As Database
Dim rs      As Recordset
Dim strHold As String
Dim strSQL  As String
Dim intType As Integer
Dim n       As Integer

    Set db = CurrentDb
    
    'Standard module = -32761; Report = -32764; Form = -32768
    strSQL = "SELECT MSysObjects.Name, Switch([type]=-32761,5,[type]=-32764,3,True,2) AS MyType" _
        & " FROM MSysObjects" _
        & " WHERE (((MSysObjects.Type) In (-32761,-32764,-32768)))" _
        & " ORDER BY Switch([type]=-32761,5,[type]=-32764,3,True,2);"
    
    Set rs = db.OpenRecordset(strSQL)
    rs.MoveLast
    n = rs.RecordCount
    rs.MoveFirst
    If n > 0 Then
       Do While Not rs.EOF
          strHold = rs!name
          intType = rs!MyType
          If (SysCmd(acSysCmdGetObjectState, intType, strHold) And acObjStateOpen) <> False Then
              docmd.Close intType, strHold, acSaveYes
          End If
          rs.MoveNext
       Loop
    End If
    rs.Close
    db.Close
    Set db = Nothing

End Sub
HTH - Bob
 
The code of the link I posted works for me in Win XP SP1 + Access 2003.
 

Users who are viewing this thread

Back
Top Bottom