Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How to open a form as Read Only ((A2K SP1))

    I have a series of forms that I want opened as read only under specific conditions. I created the forms with no actions (Addition, Deletion, Edit, Data Entry) allowed. I open the form as Read Only based on a specified condition using the following syntax:

    DoCmd.OpenForm "Form Name",,,"Where Clause", acFormReadOnly

    Access apparently ignores the Read Only clause and allows me to change any value on the form.

    Why doesn't this command work to block any editing?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to open a form as Read Only ((A2K SP1))

    It blocks editing on my forms if I use that construction to open them. But why are you even bothering to use that if you already set the form to NoEdits? That should be enough to keep them from editing any data in the form all by itself.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: How to open a form as Read Only ((A2K SP1))

    It does not work when I try either with or without the acForm action. I can change values in the underlying tables even when the Form actions are all set to no.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: How to open a form as Read Only ((A2K SP1))

    This is most peculiar - we do this kind of thing all the time and it works. If you want to fix it for certain, select all of the controls on your form and set the LOCKED property on the Data tab to Yes. Another strategy is to base the form on a query that is not updateable. But the bottom line is that turning off the edits property should make the form read-only. Is it possible your database is corrupt?
    Wendell

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: How to open a form as Read Only ((A2K SP1))

    I don't understand why it isn't working either. Are you sure your DoCmd.OpenForm syntax is correct? Maybe you have a misplaced comma.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to open a form as Read Only ((A2K SP1))

    Is this behavior peculiar to this form or this database? If so, then corruption is the obvious suggestion. But tell us more about this form. Is it bound to a table or a query? Does it have subforms? Do you have any code, behind the form or elsewhere, that could be turning the edits back on?

    And how are you changing the data in the underlying tables: directly through bound controls, or through code?
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: How to open a form as Read Only ((A2K SP1))

    Thanks to everyone for the suggestions.

    First, the reason I am trying to do this is that the underlying data is to be locked after it is approved for transmission. I did not want to have one form for editting the data and another for viewing the data after it is locked since the forms will be evolving as they are used. The problem occurs with the four forms that I open in sequence. Each is bound to a query and linked to a specific record by the open statement where clause. The data I am trying to protect is updated only through bound controls: check boxes, pull down combo boxes and text/memo fields. I cannot see any code that could change the edit / read only action other than the open statement. The systax appears to be correct and I can still edit the form without any acForm action even though the underlying form is set as Edit No. I have used the Access Compress and Rebuild function on the database several times times.

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to open a form as Read Only ((A2K SP1))

    You *can't* lock data. You can only control access to it. If you want to give the effect of locking data, you need a field in the table that you can set to True for locked. Then your forms should present that data as read-only under all circumstances.

    Are you saying you're opening 4 forms all at once? Is this the same form being opened 4 times or 4 different forms? If the latter, are all of them set up to open read-only? Locking one form will not affect the editability of records in another.
    Charlotte

  9. #9
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: How to open a form as Read Only ((A2K SP1))

    Actually I do have a field in the primary record that signifies that the record is "locked." That is what I use to determine whether I open the forms as ReadOnly or for Edit (I have a different set of forms for original data entry). The forms are opened sequentially, that is the first form loads the next form then is closed when the 2nd form opens. The 2nd form then loads the 3rd form and it tern is closed, etc. At this point all 4 forms are read only - all action parameters: data entry, add, delete, edit are set to No. All 4 open in edit mode regardless of how I open them.

    I should add that I am developing the procedures on a WIN2K system - I have experienced a number of what appeared to be issues with A2K and WIN2K - A2K appears to act differently in some ways related to record access that WIN98.

Posting Permissions

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