Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Keep VB Window Closed (A2k)

    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

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep VB Window Closed (A2k)

    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.
    Francois

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep VB Window Closed (A2k)

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

  4. #4
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep VB Window Closed (A2k)

    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.

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep VB Window Closed (A2k)

    This is a function I found in the help file.
    Maybe, with some modification, you can use this.
    <pre>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</pre>

    Francois

  6. #6
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keep VB Window Closed (A2k)

    Thanks again, I'll give it a try and see what it can do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •