• Keep VB Window Closed (A2k)

    Author
    Topic
    #414414

    Since our company has databases and internet links in various locations some people have multiple copies and versions of some of the databases.
    I’m building a faceplate that will find all the databases on a users PC and provide hyperlinks to our web sites. So far so good.
    After the database searches the hard drive it lists the database, version, and path found.
    (I have a version table in each db I create). Still working ok.
    The next step is to select the most current version of each database and click on a process button.
    This creates command buttons on the main menu for each selection. Works good. The next part I can’t get past.
    After the buttons and code behind them are created, the VB window stays open in front. I can close it manually but I don’t want the users to have to do that.
    I attached a copy of the database for anyone interested. I disabled the search and add database since the table is already populated
    and you won’t have the same databases on your pc.
    One extra question. Is there a way to delete the orphaned code (with VBA)when you remove a command button? I can see a need here when I build in the menu to
    remove the buttons and regenerate them if the user wants to restart/update the buttons.
    Thanks
    Scott

    Viewing 3 reply threads
    Author
    Replies
    • #920730

      Maybe not the most elegant manner but use senkeys at the end of the CreateCommandButtons function

      rs.Close
      SendKeys “%q”
      Set rs = Nothing

      This will produce a sound if the code exist already and the vbe editor isn’t open.

    • #920731

      Maybe not the most elegant manner but use senkeys at the end of the CreateCommandButtons function

      rs.Close
      SendKeys “%q”
      Set rs = Nothing

      This will produce a sound if the code exist already and the vbe editor isn’t open.

    • #920732

      Second possibility, (not tested) use the api function you can find at The Access Web :
      API: Close the VBE window in Access 2000

      • #920742

        Francios,
        Thanks.
        SendKeys worked. If I have time I will try the api function.

        Any ideas on removing orphaned code left behind after removing bcommand buttons.

        • #920755

          This is a function I found in the help file.
          Maybe, with some modification, you can use this.

          Function DeleteWholeLine(strModuleName, strText As String) _
               As Boolean
              Dim mdl As Module, lngNumLines As Long
              Dim lngSLine As Long, lngSCol As Long
              Dim lngELine As Long, lngECol As Long
              Dim strTemp As String
              
              On Error GoTo Error_DeleteWholeLine
              DoCmd.OpenModule strModuleName
              Set mdl = Modules(strModuleName)
              
              If mdl.Find(strText, lngSLine, lngSCol, lngELine, lngECol) Then
                  lngNumLines = Abs(lngELine - lngSLine) + 1
                  strTemp = LTrim$(mdl.Lines(lngSLine, lngNumLines))
                  strTemp = RTrim$(strTemp)
                  If strTemp = strText Then
                      mdl.DeleteLines lngSLine, lngNumLines
                  Else
                      MsgBox "Line contains text in addition to '" _
                          & strText & "'."
                  End If
              Else
                  MsgBox "Text '" & strText & "' not found."
              End If
              DeleteWholeLine = True
              
          Exit_DeleteWholeLine:
              Exit Function
              
          Error_DeleteWholeLine:
              MsgBox Err & " :" & Err.Description
              DeleteWholeLine = False
              Resume Exit_DeleteWholeLine
          End Function
        • #920756

          This is a function I found in the help file.
          Maybe, with some modification, you can use this.

          Function DeleteWholeLine(strModuleName, strText As String) _
               As Boolean
              Dim mdl As Module, lngNumLines As Long
              Dim lngSLine As Long, lngSCol As Long
              Dim lngELine As Long, lngECol As Long
              Dim strTemp As String
              
              On Error GoTo Error_DeleteWholeLine
              DoCmd.OpenModule strModuleName
              Set mdl = Modules(strModuleName)
              
              If mdl.Find(strText, lngSLine, lngSCol, lngELine, lngECol) Then
                  lngNumLines = Abs(lngELine - lngSLine) + 1
                  strTemp = LTrim$(mdl.Lines(lngSLine, lngNumLines))
                  strTemp = RTrim$(strTemp)
                  If strTemp = strText Then
                      mdl.DeleteLines lngSLine, lngNumLines
                  Else
                      MsgBox "Line contains text in addition to '" _
                          & strText & "'."
                  End If
              Else
                  MsgBox "Text '" & strText & "' not found."
              End If
              DeleteWholeLine = True
              
          Exit_DeleteWholeLine:
              Exit Function
              
          Error_DeleteWholeLine:
              MsgBox Err & " :" & Err.Description
              DeleteWholeLine = False
              Resume Exit_DeleteWholeLine
          End Function
      • #920743

        Francios,
        Thanks.
        SendKeys worked. If I have time I will try the api function.

        Any ideas on removing orphaned code left behind after removing bcommand buttons.

    • #920733

      Second possibility, (not tested) use the api function you can find at The Access Web :
      API: Close the VBE window in Access 2000

    Viewing 3 reply threads
    Reply To: Keep VB Window Closed (A2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: