Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    9

    Unanswered: Visual Basic help

    I'm trying to create a process to warn and then kick users out of a shared database so I can then open it exclusively and make changes. I've followed so advice on past posts and I think I'm close but I'm not getting any results. I've created a hidden form and included it in the autoexec so it runs in the background when the database is launched. I've put the hidden form on a timer that refreshes every 10 seconds. Here's the code behind the event procedure tied to the timer:

    Private Sub Form_Timer()
    If [Table]![SHUTDOWN]![Action] = "NOTHING" Then
    DoCmd.RunMacro "STOPMACRO"
    ElseIf [Table]![SHUTDOWN]![Action] = "WARNING" Then
    DoCmd.OpenForm "WARNING"
    ElseIf [Table]![SHUTDOWN]![Action] = "SHUTDOWN" Then
    DoCmd.RunMacro "SHUTDOWN"
    End If

    End Sub

    I have a table called SHUTDOWN with a single field called Action with a single value that I will change to cause 1)NOTHING - run a STOPMACRO macro that does nothing 2) WARNING - a warning form to popup telling users to save and logout 3) SHUTDOWN - a macro called SHUTDOWN that has a RUN COMMAND to EXIT the database. I'm not a Visual Basic guy so the code may be off. Right now when the database is launched it's doing nothing no matter what value is in the SHUTDOWN table. Does anybody have a suggestion.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Just a few wee things -

    I would do this less than every ten seconds unless you will really need to boot people out at the drop of a hat. I would have thought 5 mins (set the table value, make a brew, google some Norweigen poetry and then return to your task at a leisurely pace) would be plenty.

    Why bother calling a macro that... does nothing?

    Anyhoo - how about:
    Code:
    Private Sub Form_Timer()
     
    Dim MyString As String
     
    MyString = NZ(DLookup("Action", "Shutdown"), "Nothing")
    
    If MyString = "NOTHING" Then
    'Do nothing. In fact -  even the test can go
    'DoCmd.RunMacro "STOPMACRO"
    ElseIf MyString  = "WARNING" Then
    DoCmd.OpenForm "WARNING"
    ElseIf MyString  = "SHUTDOWN" Then
    DoCmd.RunMacro "SHUTDOWN"
    End If
    
    End Sub
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    BTW - if I asked if you have split your front and back ends would you wince in sympathetic pain or would you know what I am talking about?
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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