Unlocking Lookup without Unlocking Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SoNew
    New Member
    • Mar 2008
    • 13

    Unlocking Lookup without Unlocking Form

    To say I'm new is an understatement - but somehow my boss decided I was the one to create a database in Access 2003...I'm nearly there. I have a small problem in that I have locked the main form (although not yet the subform) using:
    Code:
    Private Sub Form_Current()
    If Me.NewRecord Then
        Me.AllowEdits = True
    Else
        Me.AllowEdits = False
    End If
    End Sub
    Then I have an Edit Button that folks can push to change data as needed - using:
    Code:
    Sub cmdEdit_Click
    On Error GoTo Err_cmdEdit_Click
     
       Me.AllowEdits = True
     
    Exit_cmdEdit_Click:
        Exit Sub
     
    Err_cmdEdit_Click:
        MsgBox Err.Description
        Resume Exit_cmdEdit_Click
     
    End sub
    But I have a lookup box that shows all the students - I need to be able to have people navigate to the record using the Lookup, without yet being able to edit. But the Lookup is locked until the Edit Button is pushed. I would like them to use the Lookup, select the student and have the data load into the form - without them being able to edit it until the push the Edit Button. FYI the Lookup is part of the Main Form.
    Is this possible?
    Thanks!
    Last edited by NeoPa; Mar 15 '08, 01:03 AM. Reason: Please use [CODE] tags
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Sure! In the combobox's On Got Focus event set AllowEdits to True and in it's On Lost Focus event set AllowEdits back to False.


    Welcome to TheScripts!

    Linq ;0)>

    Comment

    • SoNew
      New Member
      • Mar 2008
      • 13

      #3
      You are BRILLIANT! Thank you - works great!! :)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Actually, I'm also quite impressed (Brilliant is not wrong). Neat answer Linq.

        As for SoNew, I have to admit that your question is well explained and the given code far from n00bish. I've seen many members that couldn't handle that even after a long time posting on the site. Maybe your boss is not so stupid after all ;)

        I certainly wish all questions were as clearly stated.

        Welcome to TheScripts :)

        Comment

        Working...