Results 1 to 11 of 11
  1. #1
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183

    Locking fields in Access form

    I have 4 questions (4 fields) in a form. 2 are drop down menu type and 2 are open text fields.


    I would like to limit the user from entering data in the fields if one has been answered.

    for example:
    if Question one is answered, question 2, 3 and 4 should be locked and should not allow the users to fill in anything.

    How do I create that Locking system?

    Thanks,

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,953
    Generally, this type of thing:

    http://www.baldyweb.com/ConditionalVisibility.htm

    but using the Locked property instead of Visible.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    Generally, this type of thing:

    http://www.baldyweb.com/ConditionalVisibility.htm

    but using the Locked property instead of Visible.
    Thanks Pbaldy..

    That would work for drop down menu.
    What about for open text field? is there such such like me.controlname.value = true?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,953
    Sure; in your case you're testing to see if it contains anything, so your test would be:

    If Len(Me.SomeControl & vbNullString) = 0 Then

    which tests for both Null and a zero length string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    Sure; in your case you're testing to see if it contains anything, so your test would be:

    If Len(Me.SomeControl & vbNullString) = 0 Then

    which tests for both Null and a zero length string.

    I almost got it to work one time but something/somewhere is I did it wrong.
    under after update
    If Len(Me.National & vbNullString) = 0 Then
    Me.Combo877.Visible = False
    Me.procombo.Visible = False
    Me.International.Visible = False

    Else
    Me.Combo877.Visible = True
    Me.procombo.Visible = True
    Me.International.Visible = True
    Me.National.Visible = True

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,953
    What error do you get, or what happens incorrectly? Based on what you posted, you're missing

    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    What error do you get, or what happens incorrectly? Based on what you posted, you're missing

    End If
    Very strange.
    I don't get an error message. Nothing happens to it.

    Private Sub national_AfterUpdate()

    If Len(Me.National & vbNullString) = 0 Then
    Me.Combo877.Visible = False
    Me.procombo.Visible = False
    Me.International.Visible = False

    Else
    Me.Combo877.Visible = True
    Me.procombo.Visible = True
    Me.International.Visible = True

    End If

    End Sub
    I also tried with
    If Len(Me.National & vbNullString) = 1
    , it did not work too

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,953
    Are you changing the contents of that control? Is any code running (is the db in a trusted location)?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    Are you changing the contents of that control? Is any code running (is the db in a trusted location)?
    I don't think so.
    I am going to check my forms now.

  10. #10
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    Are you changing the contents of that control? Is any code running (is the db in a trusted location)?
    for some reasons, I can't get it to work.. .. I created a new form for testing and it did not work too.

    Private Sub test1_AfterUpdate()

    If Len(Me.test1 & vbNullString) = 1 Then
    Me.test2.Visible = False
    Me.test3.Visible = False

    Else
    Me.test2.Visible = True
    Me.test3.Visible = True


    End If
    End Sub

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,953
    Can you post the db here?
    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. Locking a tab in a tabbed form
    By focosi in forum Forms
    Replies: 7
    Last Post: 09-21-2011, 04:25 PM
  2. Locking a field inside a form
    By cggriggs in forum Forms
    Replies: 2
    Last Post: 06-11-2011, 06:02 PM
  3. Locking Down Form
    By jo15765 in forum Forms
    Replies: 5
    Last Post: 11-16-2010, 04:44 PM
  4. Locking fields
    By Icewolf0927 in forum Forms
    Replies: 3
    Last Post: 09-23-2010, 12:01 PM
  5. Access Locking other users out
    By David in forum Access
    Replies: 1
    Last Post: 07-02-2009, 09:26 PM

Posting Permissions

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