Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2009
    Location
    Franklin, OH
    Posts
    44

    Question Unanswered: Problem with opening a form in "Read Only" Mode

    I have an access 2007 DB. I would like to open a form in "Read Only" mode, but it does not work for some reason. Every time I open the form, I am able to edit it and the changes are saved.

    Here is the code I am using from a button to open the form:

    Code:
    Private Sub btn_Find_BOL_Click()
    Dim stForm As String
    Dim stWhere As String
    
    stForm = "Load Sheet"
    stWhere = "tbl_LoadSheet.BOL_Number = [Enter BOL#]"
    
    DoCmd.OpenForm stForm, acNormal, , stWhere, acFormReadOnly
    
    End Sub
    I have also tried using a macro for this, but (a) macros are not my friend, and (b) it did not work either.

    I am thinking that there could possibly be a setting that I am not seeing.

    Thanks in advance for your help.

  2. #2
    Join Date
    Sep 2009
    Posts
    44
    Make up a minimal test case: an MDB file with one table, one form with the launching button, and one form with a single text field linked to the table, to show us exactly what you're doing.

    If you want to avoid accidentally exposing your data, I'd suggest you start with a blank MDB and build up rather than stripping an existing MDB down.

  3. #3
    Join Date
    Aug 2009
    Location
    Franklin, OH
    Posts
    44
    I made the test DB with one table and 2 forms. The button worked properly in the test DB, so I opened the live DB and checked to ensure the code was essentially the same, and it was. So I tried again in the live DB, with the same result of the form that was opened was editable.

    It must be a setting on the form I have changed.

    Thanks for your help Scooby.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    The next thing I'd look at it is the code for the form itself. If you're relatively certain that everything up to and including the call to open the form is correct, that would be the next logical step.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    A frequently overlooked way of making a form is to set the RecordSet Type Property to Snapshot. You might try that.

    As to why it's behaving the way it is:

    How have you currently got the form "locked?"

    Are any fields automatically populated on the form, including something like a "click?" If you have AllowEdits set to No and then populate a field thru code, the record is then 'unlocked' until you navigate to another record.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Deleted as duplicate. Sorry!
    Last edited by Missinglinq; 12-26-09 at 10:24.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You can also control how the form opens for editing using this type of command:

    docmd.openform "MyFormName"
    Forms!MyFormName.AllowEdits = False
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Aug 2009
    Location
    Franklin, OH
    Posts
    44
    About 1/3 of the form is populated through code. I guess then it would be "unlocked".

    As a temporary solution I have added a MsgBox that asks the user to if they would like to save the form before closing.

    I tried pkstormys idea, but the form remains editable.

    I will try to set the RecordSet to Snapshot and see if that will work.

    Thanks for the ideas.

  9. #9
    Join Date
    Aug 2009
    Location
    Franklin, OH
    Posts
    44
    Revision,

    pkstormys idea did work. It will allow the user to type in the fields, but it will not save the form with the changes , even if the user selects Yes from the save MsgBox.

    Thanks for the help guys.

Posting Permissions

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