Results 1 to 4 of 4
  1. #1
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65

    How do I Lock text boxes so I cant complete the record unless they are all filled out


    I have a form that has a event proceadure after I select a name it refreshes the record and a DLook up fills out all of the associates info from another table. I have 5-15 text boxes that need to be filled out after that happens and I want it to not allow the user to skip a box with out filling out the box. I tried a validation rule not null and validation text which works only if I fill out the text box then deleted the text, then it won't let me go foward. Any Ideas out there?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Well, first off, you don't want to lock the text boxes, because then you cannot enter anything into the text boxes.

    Second, I would use the form Before Update event to check that the required controls have data entered. If all of the required controls do not have the data, cancel the update and display a message. You can also position the focus to the control and/or display a message to cancel the record.

    And third, if you are using a combo box to select the name, instead of using DLookup(), I would try and use the combo box row source to get all of the associates info and push it into the associated controls. Much faster and I think would be less code.

  3. #3
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    Your right I dont want to Lock the text box wrong word SO how to you do the 2nd thing?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You could use a series if IF statements to check if the control has data and cancel the update if the control was Null amd/or ask if the record should be canceled.

    (use your control names)
    Code:
    Sub Form_BeforeUpdate(Cancel as Integer)
    
    'check Last Name control
    If Len(Trim(Me.LName))=0 Then
       Msgbox "Please enter the Last name", vbOKOnly, "Missing Last Name"
       Me.LName.SetFocus
       Cancel = True
    End If
    
    'check first Name control
    If Len(Trim(Me.FName))=0 Then
       Msgbox "Please enter the First name", vbOKOnly, "Missing First Name"
       Me.FName.SetFocus
       Cancel = True
    End If
    
    etc..
    
    
    End Sub

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 9
    Last Post: 05-12-2012, 12:16 PM
  3. fields automatically filled in a new record
    By fabiobarreto10 in forum Forms
    Replies: 9
    Last Post: 04-09-2012, 05:18 PM
  4. Replies: 0
    Last Post: 10-14-2009, 02:44 AM
  5. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 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
  •  
Other Forums: Microsoft Office Forums