Results 1 to 6 of 6
  1. #1
    Csalge is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    31

    subforms allowing additions


    I want to prevent a subform from allowing additions based on an unbound field in my main form. Right now i have this and it's not working:
    If Me.Text47 <= 0 Then
    Me.child2.Form.AllowAdditions = False
    Else
    Me.child2.Form.AllowAdditions = True
    End If
    End Sub

    any suggestions?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why isn't it working, what happens - error message, wrong results, nothing?

    What event is that code in?
    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.

  3. #3
    Csalge is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    31
    I have it on current event of my main form. Nothing happens. I dont get an error but when my unbound equals zero my subform does not prevent users from adding records. My subform is a continuous form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What do you mean 'when my unbound equals zero'? Text147 is an unbound box? How does the box equal anything? If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  5. #5
    Csalge is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    31
    Databaseissue.zip

    The unbound field shows employees their daily available hours (deducting excluded time from second subform). Text47 is total available hours. If total available hours show as zero i do not want employee to be able to enter any production points.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Problem is the main form Current event runs before the subform is fully loaded so the calcs that are dependent on subform are errors and the code has run-time error. You can see this if you put a breakpoint in Current event.

    Suggest code behind subfrmProduction:

    Private Sub Form_GotFocus()
    If Forms!frmEmployee.Text47 <= 0 Then
    Me.AllowAdditions = False
    Else
    Me.AllowAdditions = True
    End If
    End Sub
    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: 9
    Last Post: 10-17-2012, 11:37 AM
  2. acFormEdit is allowing form additions
    By kelann in forum Forms
    Replies: 2
    Last Post: 10-17-2012, 11:22 AM
  3. Allow Additions Msg Box
    By rossi45 in forum Forms
    Replies: 3
    Last Post: 04-23-2012, 02:51 PM
  4. Allow additions on .accdr
    By dougie in forum Forms
    Replies: 0
    Last Post: 02-20-2012, 05:17 AM
  5. Multi-record additions using a list box not working right
    By avarusbrightfyre in forum Programming
    Replies: 3
    Last Post: 10-27-2010, 01:50 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