problem with global variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henrik Thomsen

    #1

    problem with global variables

    hi ng

    I got two huge problems:

    1)
    I have made a database that saves a users username a public variable when
    the database opens.
    When the database is shot down I wan't to save the time the user is leaving
    the database, and in the "mainmenu form" I have made some vba under the
    event: "shot down"

    here it is:
    Private sub form_close
    Dim db As Database
    Dim RSTOUT As Recordset
    Dim strSQL As String

    Set db = CurrentDb

    strSQL = "select * from Tbl_BrugerLog"
    Set RSTOUT = db.OpenRecordse t(strSQL)

    With RSTOUT
    .AddNew
    !Bruger = strUsername
    !Tidspunkt = Now()
    !Tekst = "Logger af"
    .Update
    End With
    RSTOUT.Close

    end sub

    My problem is that it seems to reset the global variable just before it is
    shotdown, so there is saved no name (the public variable is strUsername).

    2) How do I hide the buttom in the right upper-corner that shot down the
    database and access it selve?


    Thanks in advance
    Best regards
    Henrik



  • Tim Marshall

    #2
    Re: problem with global variables

    Henrik Thomsen wrote:[color=blue]
    >
    > When the database is sh[u]t down I wan't to save the time the user is leaving
    > the database, and in the "mainmenu form" I have made some vba under the
    > event: "sh[u]t down"[/color]

    Henrik, is the main form open throughout the session? If so, save the
    user name on a text box on the form and make the text box visible
    property false.

    [color=blue]
    > 2) How do I hide the buttom in the right upper-corner that shot down the
    > database and access it selve?[/color]

    As far as I know, you can't. If the user shuts down the database and
    your main form is open, it will close first, firing its on close event.
    That's the sort of thing I always use.

    --
    Tim - http://www.ucs.mun.ca/~tmarshal/
    ^o<
    /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
    /^^ "Want some?" - Ditto

    Comment

    • Henrik Thomsen

      #3
      Re: problem with global variables

      thanks alot Tim
      "Tim Marshall" <tmarshal@Gunne r.Sabot.Spam.On .Loaded.FIRE> skrev i en
      meddelelse news:3F75DFC2.B 849CCAA@Gunner. Sabot.Spam.On.L oaded.FIRE...[color=blue]
      > Henrik Thomsen wrote:[color=green]
      > >
      > > When the database is sh[u]t down I wan't to save the time the user is[/color][/color]
      leaving[color=blue][color=green]
      > > the database, and in the "mainmenu form" I have made some vba under the
      > > event: "sh[u]t down"[/color]
      >
      > Henrik, is the main form open throughout the session? If so, save the
      > user name on a text box on the form and make the text box visible
      > property false.
      >
      >[color=green]
      > > 2) How do I hide the buttom in the right upper-corner that shot down the
      > > database and access it selve?[/color]
      >
      > As far as I know, you can't. If the user shuts down the database and
      > your main form is open, it will close first, firing its on close event.
      > That's the sort of thing I always use.
      >
      > --
      > Tim - http://www.ucs.mun.ca/~tmarshal/
      > ^o<
      > /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
      > /^^ "Want some?" - Ditto[/color]



      Comment

      Working...