Results 1 to 7 of 7
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Form/Subform problem

    I'm using the tabbed feature to have subforms in a form. Unfortunately, it's possible to add information in the subform even when the main form is showing NEW. So, the subform information isn't related to anything. How do I make it so that the subform cannot have information added until the main form has been created?

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    You could hide the subforms by default and only make them visible when there is data in the main form.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I've used this before:
    Code:
    Private Sub Form_Current()
      
     If Me.NewRecord Then
      Me.SubFormName.Locked = True
     Else
      Me.SubFormName.Locked = False
     End If
     
    End Sub
    
    Private Sub MainControl1_AfterUpdate()
    
     If IsNull(Me.MainControl1) Then
      Me.SubFormName.Locked = True
     Else
      Me.SubFormName.Locked = False
     End If
    
    End Sub

    Note that SubFormName is the name of the Subform Control...not the Form that resides there...which may or may not be the same!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    That got me thinking a bit better. I tried something simple:
    Private Sub Form_Current()
    If IsNull(IncidentID) Then
    Me.tabICS209.Enabled = False
    Else
    Me.tabICS209.Enabled = True
    End If
    End Sub

    Would this work?

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    You're code worked well. Do I need the after update also or just the on current?

  6. #6
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Had to take time away for a bit. That worked excellent. Thanks.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Form With subform problem
    By banpreet in forum Forms
    Replies: 2
    Last Post: 12-22-2016, 11:33 AM
  2. One to many form/subform problem
    By wolfm in forum Forms
    Replies: 3
    Last Post: 10-10-2014, 01:29 AM
  3. Form / subform problem
    By ksmith in forum Programming
    Replies: 5
    Last Post: 08-30-2011, 07:33 AM
  4. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  5. Form-Subform-Popup Problem
    By TrudyD1474 in forum Forms
    Replies: 1
    Last Post: 06-10-2010, 05:36 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