Results 1 to 2 of 2
  1. #1
    fcbuek is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6

    Access Lock columns when the other is empty

    Hi,
    I have such a problem. In Access I have a form in which I have also inserted a subform in which there is only one column (NRB tables are linked one to many). I have a question whether it is possible to add a subform so that you can only enter some data in the NRB column as the TEST2 text field is filled in the main form.

    I entered this code in the form


    Code:
    Private Sub Test2_Select() 
    If (Test2.Value = "" Or IsNull(Test2.Value)) Then Test2.Select 
    End Sub
    But it doesn't work because I would like it to be impossible to enter data in the NRB column as the Test2 column is empty. I attach an example in the attachment.


    Thank you in advance for your help.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Instead of NRB_Click, use NRB_GotFocus for SelStart.

    Clean up code. There is a sub for Check_GotFocus but I can't find a control named Check.

    Code on main form to lock NRB textbox is incorrect syntax. Instead of locking NRB textbox, lock [NRB podformularz1] subform container control.
    Code:
    Private Sub Form_Current()
        Me.NRB_podformularz1.Locked = IsNull(Me.Test2)
    End Sub
    
    Private Sub TEST2_AfterUpdate()
        Me.NRB_podformularz1.Locked = IsNull(Me.Test2)
    End Sub
    

    Advise not to use spaces in naming convention.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 11-13-2017, 02:09 PM
  2. Replies: 1
    Last Post: 01-19-2017, 10:13 AM
  3. Replies: 1
    Last Post: 04-15-2014, 02:45 PM
  4. Replies: 2
    Last Post: 04-23-2012, 10:13 PM
  5. Deleting empty columns from a table
    By kapil0712 in forum Programming
    Replies: 3
    Last Post: 05-17-2010, 12:35 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