Form "ReadOnly"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elainenguyen
    New Member
    • Oct 2006
    • 51

    Form "ReadOnly"

    Hi,
    since assigned "acFormReadOnly ", my code supposes to allow user to only "read the form", but when I test the code, I can type and click on any of the fields on the form. What I really want the code to do is not allow user to be able to click or type on any of the fields, on the form. Any idea? please help.

    Code:
      
    Dim db As Database
        Dim rst As Recordset
        Dim stLinkCriteria As String
      
        Set db = CurrentDb
        Set rst = db.OpenRecordset("tblReview", dbOpenDynaset)
        rst.FindFirst "[ID] = " & Me![txtRECID] & ""
        stLinkCriteria = "[ID]=" & Me![txtRECID]
        DoCmd.OpenForm "frmReview", , , stLinkCriteria, acFormReadOnly
    thanks!
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    Opening the form ReadOnly only stops you updating the data. It doesn't disable the functionality of the controls on the form.

    To do this loop through all the controls and set them to disabled. Some code similar to the following would be required :
    Code:
    Dim ctlMe As Control
    
    On Error Resume Next
    For Each ctlMe in Me.Controls
      ctlMe.Enabled = False
    Next ctlMe
    On Error GoTo 0
    This all assumes you can't simply set them all from Design-mode. If that's possible it's much easier. Unfortunately, even .Locked controls still drop down even though their values won't change.

    Comment

    • elainenguyen
      New Member
      • Oct 2006
      • 51

      #3
      thanks for your help. Is there a way to do ViewOnly instead of ReadOnly?
      thanks!

      elaine

      Comment

      • hjozinovic
        New Member
        • Oct 2007
        • 167

        #4
        Try using:
        Code:
        Set rst = db.OpenRecordset("tblReview", dbOpenSnapshot)

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Elaine, you're not being very clear about what you need here I'm afraid.

          There is no way to set an otherwise updatable form to read/only simply by setting something in the form. At least not so that the ComboBox controls are disabled from opening. Opening it with DataMode:=AcFor mOpenDataMode will ensure the data isn't changed, but the ComboBoxes will still drop down

          To stop them dropping down they need to be set .Enabled = False. This will also show them as dimmed on a grey background.

          I hope this answers your question. If not, please specify it a little more clearly & I will be better able to help.

          Comment

          • DonRayner
            Recognized Expert Contributor
            • Sep 2008
            • 489

            #6
            Add your form as a subform on a new form. Delete the subform label and set the subform properties as follows

            Special Effect = Flat
            Border Style = Transperent
            Enabled = No

            This will do exactly what you are asking. User will not be able to click onto anything contained in that subform.

            Comment

            Working...