Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Howto set application-wide variables? Read inside

    Hello everyone,

    me again, I know I'm annoying <img src=/S/smile.gif border=0 alt=smile width=15 height=15> I have this Year Form popping up in the beginning of the Application start (see screenshot). Right now I have a =Year(Now()) as standard-value for that drop down box - but now I want it different!
    I created a new System Variable table:

    tblSys
    Title
    Value

    with the [WorkingYear] item. Now what I want is that the user can select 2009 from the drop down list, then click "Set..." and that year is set forever or until he selects another year and hits OK or selects another year and hits the Set... button again.
    So the Standard Value for the dropdownbox must be the tblSys WorkingYear field and the button must "set" it somehow via script I guess - but I'm not that good with scripting... so thats up to you

    I hope you get what I mean!

    Dennis

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Howto set application-wide variables? Read inside

    Do you have more than one user?
    If so, do you have a split frontend/backend design where each user has his/her own copy of the frontend?
    If not, the setting would apply to all users - if one of them changes the year, that year would be the default for the others too.
    You could get around this by including the user name in the table, but the code would become more complicated.

  3. #3
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Howto set application-wide variables? Read ins

    Not yet splitted but will be splitted and only ONE user. Can be more users but everyone will be working with the same year, so thats alright!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Howto set application-wide variables? Read ins

    OK, it shouldn't be difficult then. Can you tell us:
    - The name of the combo box.
    - The name of the table.
    - The meaning of Title and Value. In other words, how is the year stored in the table?

  5. #5
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Howto set application-wide variables? Read ins

    Sure.

    cboYear - the combo box
    tblYear (holds all the years in the cboYear) or tblSys (for the Variables) - the tables

    take the meaning of title and value from the screenshot

    Dennis

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Howto set application-wide variables? Read ins

    In the On Load event of the form:

    <code>Private Sub Form_Load()
    Me.cboYear = DLookup("Value", "tblSys", "Title = 'Working Year'")
    ' if you have other code, it goes here
    End Sub</code>
    In the On Click event of the Set... thingy (forgot to ask its name)

    <code>Private Sub SetThingy_Click()
    Dim strSQL As String
    strSQL = "UPDATE tblSys SET [Value] = '" & Me.cboYear & "' WHERE Title = 'Working Year'"
    CurrentDb.Execute strSQL
    End Sub</code>

  7. #7
    2 Star Lounger
    Join Date
    Jun 2004
    Location
    L, Schleswig-Holstein, Germany
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Howto set application-wide variables? Read ins

    Works like a charm. thanks again Hans!

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Howto set application-wide variables? Read ins

    Glad it works. You now have a powerful and flexible mechanism for setting and retrieving user and system preferences.

Posting Permissions

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