Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    persisting data outside of storing in a table (Access2K, Win2K Pro)

    I had a request to create a locking mechanism in an Access db, which basically involved setting various form controls to Locked=False or True, depending. I thought it'd be awfully clever of me to store the state of the button on a hidden form element but that didn't work. So I created a table to store the state of the button and set it to "Hidden" and password-protected the VB module to prevent snooping the code for the magic Unlock password. Obviously, this is, like most times when I think of securing access, a half-a$$ed solution.

    What i'd like is a way to store the state of the button in some funky way not dependent on a table, like, for example, some form field property that is rarely used and never looked at or not understood, like, say, IME Mode. I thought I'd ask you guys if this idea is not only strange but retarded - or if there's some other way people have used to get around depending on users not to know to view Hidden objects. FWIW, I am not all that concerned about this project's security being compromised as it is - I'm "ok" with the protections in place, just being a bit nerdy.

    TIA

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

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    What's wrong with a table? It is the 'natural' way to store information in a database...

    You could, however, store information in custom properties of the form. You can use DAO properties or Access properties. Both can only be read or set using VBA, they are not visible in the Access interface.

    Here is an example of creating/setting a custom Access property:

    CurrentProject.AllForms("frmTest").Properties.Add "cmdButton1Visible", "True"

    and an example of its use:

    Me.cmdButton1.Visible = CurrentProject.AllForms("frmTest").Properties("cmd Button1Visible")

    Note: if you Add an existing property a second time, the original one is overwritten, you don't get an error message.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    I didn't want to store the button state in a table as it is perfectly easy for a user to unhide the table, open it and change the value to "unlock" the form. of course, I have code in place to check if any unexpected value is stored in the table which is a slight help, but if I could save a state in some little corner of the UI and read from that it would be better.

    I tried your suggestion, but wanted to adapt it to set some setting other than visibile/not visible to a control as that would be easy to spot to a user. Some esoteric like setting IMEMode settings appeals to me. Haven't really dug around on this whole idea, to tell the truth. It's more of a concept - but I have some spare time so may play around with it....

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

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    Access properties are always string values; that is not really a restriction, but if you use DAO properties, you can specify the data type too (dbText, dbBoolean, dbLong, etc.)

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    well, the problem I am running into is, I can set a property in VB but when the form is closed and re-opened, the property just set gets erased. I tried setting a value to the button's Tag property, BTW.

    what I need is some way to save the set property after the click event. This was my original problem, which is why I just gave up and went to using a table lookup and all that sort of thing. I suspect this is just an odd thing to do!

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

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    If you set the Tag property of a control, it's just like setting the Visible property of the control: the value remains effective until the form is closed. Next time you open the form, the value set in design view is in force again. You'd have to use code to open the form in design view, set the property, then save and close the form, but that is very unattractive.
    The methods I described in my previous replies will result in persistent properties, though.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: persisting data outside of storing in a table (Access2K, Win2K Pro)

    Ok, I'll tool around with setting using Access or DAO properties. I noticed if you have the controls property sheet open and *type* a change, close and save, it is preserved. Setting the property directly from VBA doesn't trigger the save changes which agrees with the behavior discussed, viz. properties live only for the life of the form.

    The typing observation made me think of using the dreaded Sendkeys on the .Tag property in VBA - so far no luck getting that to work.

Posting Permissions

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