Results 1 to 7 of 7
  1. #1
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58

    Enabling Filtering and Searching in a Read-Only form

    I have a form that opens to read-only based on user role. I need to be able to use a Lookup List (Combo box) to still be used to search for records as well as a lookup list that filters records but they don't work in the read-only mode.
    The two controls that i want to still be able to use are cboFilterDept and the Combo329.


    Here is a snippet of the code i am trying to use to do this...
    ================================================== ===============================
    If (DLookup("strUserRole", "tblUserRoles", "[strUserID]='" & Forms![_frmLoginVerify]!txtLoginName.Value & "'")) = "Admin" Then

    DoCmd.OpenForm "frmAgreements_Edit"


    ElseIf (DLookup("strUserRole", "tblUserRoles", "[strUserID]='" & Forms![_frmLoginVerify]!txtLoginName.Value & "'")) = "MC Reporting" Then

    DoCmd.OpenForm "frmAgreements_Edit", acNormal, , , acFormReadOnly
    Forms!frmAgreements_Edit.Controls("cmdNewAgreement ").Visible = False
    Forms!frmAgreements_Edit.Controls("cboFilterDept") .AllowEdits = True
    Forms!frmAgreements_Edit.Controls("Combo329").Allo wEdits = True



    Else
    MsgBox "Sorry, you do not have permission to use this area of the database", vbOKOnly, _
    "Permissions Check"


    End If
    ================================================== ===================================

    Any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Can't. Even unbound controls cannot be edited if form is read only. Will have to change the read only setting to allow the inputs for search/filter then reinforce read only after search/filter.

    Or build form/subform. Search controls on main form, subform container is locked, code sets Filter property of subform.

    Or code locks each data control individually.

    AllowEdits is not a property of combobox, it is property of form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    istari88 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Kentucky, USA
    Posts
    13
    Get the value of the DLookup this way and then run thru the IF's:

    AccountBalance = DLookup("[CalcBalance]", "qryAccountCalculations", "[AccountID]=" & ActID)
    IF var=AccountBalance then...


    Maybe a Me.Recordset.Clone can be used...
    Private Sub Combo18_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[StudentRef] = " & Str(Me![Combo18])
    Me.Bookmark = rs.Bookmark
    End Sub

  4. #4
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58
    Thanks for the response.
    Can you give me some example code that would keep the form read-only but allow search/filter to work.
    Appreciate it.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You can toggle the AllowEdits property of the form in the Got/Lost Focus events of the search controls.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58
    Thanks!
    The Got/Lost Focus did the trick.
    Again thanks for the response.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 03-27-2018, 01:09 PM
  2. Enabling and Disabling Buttons on a Form.
    By Slurry Pumper in forum Forms
    Replies: 10
    Last Post: 11-14-2016, 10:07 AM
  3. Enabling controls on a form
    By crowegreg in forum Programming
    Replies: 4
    Last Post: 08-22-2013, 09:18 AM
  4. Issue with searching and filtering query
    By federer8 in forum Queries
    Replies: 1
    Last Post: 02-08-2013, 06:21 PM
  5. Enabling fields in form
    By Kivan in forum Programming
    Replies: 8
    Last Post: 08-22-2012, 03:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums