Results 1 to 6 of 6
  1. #1
    Roadbeer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    19

    limiting records on a continuous subform question

    Hey all,



    I'm trying to limit the number of records that can be entered in a continuous subform based off the selection of a combo box on it's main form.

    For instance, If I select 3 in the combo box, I want to limit the number of records that appear in the subform to not exceed 3 and suppress the 4th from appearing.

    Any thoughts?

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You want subform to be filtered so only a specified number of existing records will be displayed? Never seen that. What is purpose?
    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
    Roadbeer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    19
    New records to be displayed.

    I'm trying to make a fool-proof registration form for an organization

    If a member has 3 guests, on the member form when 3 is selected from the combo box, the continuous sub-form will only allow 3 records to be added to the table 'guests'

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, that's different.

    The real trick is figuring out what event to use - maybe the form BeforeUpdate.

    Try something like:

    Have a textbox in subform header or footer with expression: =Count("*")

    Then code behind the subform:

    Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.NewRecord And Me.textboxname = Me.Parent.comboboxname Then
    MsgBox "Whatever message you would like to display to the user."
    Cancel = True
    Me.Undo
    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.

  5. #5
    Roadbeer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    19
    Thanks June, with a slight modification it worked.

    For some reason the =Count("*") wouldn't stop adding records, but when I bound a text box to the tables PK and set the expression to =Count([ID]) it worked.

    Now just for aesthetics, is it possible to suppress the second message box that comes up after the first that says "You can't go to the specified record"?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't think I got that message when I tested code. If you want to provide your db for analysis, I will try to determine solution.
    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. continuous form question
    By dadofgage in forum Forms
    Replies: 1
    Last Post: 10-17-2012, 03:38 PM
  2. Question on database structure - limiting linked records
    By andrewb in forum Database Design
    Replies: 2
    Last Post: 03-22-2012, 05:41 PM
  3. Form limiting records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-21-2011, 06:50 AM
  4. limiting amount of records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-17-2011, 07:01 PM
  5. Replies: 25
    Last Post: 03-31-2010, 11:10 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