Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Read Only (A2000)

    GMA,

    I have all my code worked out except for 1 tiny thing. What I would like to know is, how in code can I restrict ALL of the form to read only? This will go in a Case statement.

    i.e

    Case Select (strAccLvl)

    Case "Developer"
    Me.cmd1.visible=true
    Case "Data"
    Read Only

    Hope this is clear....and many thanks.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Read Only (A2000)

    The following instructions turn off editing existing records, creating new records and deleting existing records, respectively:

    Me.AllowEdits = False
    Me.AllowAdditions = False
    Me.AllowDeletions = False

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Read Only (A2000)

    Hans,

    Thanks. I shouldn't have been so quick to ask....I figured it out by the time you replied.....but thanks just the same.

    Have a great weekend.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Read Only (A2000)

    OK....I have another idea.....I would like to know how I can apply this to a PUBLIC Function. I will be using this quite often. Rather than writing it over and over again, I would rather call the Function.

    Me.AllowAdditions = False
    Me.AllowEdits = False
    Me.AllowDeletions = False
    Me.AllowDesignChanges = False

    I know the "ME" has to be omitted. I want the rest to be applied to whatever form I call the function from.

    Thanks.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Read Only (A2000)

    You can replace Me by CodeContextObject. This refers to whatever object is running the code.

    Or, another approach:

    Public Function LockForm(frm As Form)
    frm.AllowAdditions = False
    frm.AllowEdits = False
    frm.AllowDeletions = False
    frm.AllowDesignChanges = False
    End Function

    Call it as LockForm Me in a VBA routine, or as =LockForm([Form]) directly in the Event tab of the Properties window.

  6. #6
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Read Only (A2000)

    Thanks so much Hans....guess this VBA thingy is finally catching on....I almost had it, was missing the "frm as form" part.

    Once again, many thanks.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  7. #7
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Read Only (A2000)

    Hans,

    It works fine, but I have another tiny ?...If I allow this:

    frm.AllowDesignChanges = False***************** when hightlighted in de###### it shows TRUE but,

    error msg says I can't assign a value to this object.

    If I omit it the code runs fine, why?

    I don't want to allow design view, so what else should I use?
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Read Only (A2000)

    I would set Allow Design Changes to No in design view, then you won't have to set it in code. I never allow the end user to make design changes.

Posting Permissions

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