Results 1 to 3 of 3
  1. #1
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49

    how to add new item until 10 row

    hello to all friends

    with a view to sample ، I can Add (insert)
    unlimited item from subform1 into subform2 .

    question :
    A : How can I add only 10 Items into the subform2 ??
    B : and for add Item of equal 11th and then , I want display Error message??



    Thankyou for your help
    Attached Files Attached Files

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not really sure what you want, but try this: (quick and dirty)
    Code:
    Private Sub cmdCopyFName_Click()
        Dim RC1 As Integer
        Dim RC2 As Integer
        Dim SumRC As Integer
    
        'number of selected (Aproved) records in table1
        RC1 = DCount("*", "table1", "Aproved = TRUE")
        
        'number of existing records in table2
        RC2 = DCount("*", "table2")
    
        SumRC = RC1 + RC2
        
        If SumRC <= 10 Then
            CurrentDb.Execute "INSERT INTO TABLE2 (Fname, Lname, Phone, Aproved) SELECT Fname, Lname, Phone, Aproved FROM Table1 WHERE [Aproved];", dbFailOnError
        Else
            MsgBox "ERROR Message!!! Adding the aproved records would create more than 10 records in table2"
        End If
        
        Me.Table2_sub.Requery
    End Sub
    Allows a maximum of 10 records in Table2.

  3. #3
    zozzz is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    49
    very fantastic my friend (ssanfu) ....
    good job
    Thank you very much

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

Similar Threads

  1. Replies: 30
    Last Post: 07-03-2014, 01:22 PM
  2. Mask each item
    By luckasx in forum Access
    Replies: 3
    Last Post: 11-27-2013, 09:19 AM
  3. Searching For Last Item
    By andresdm in forum Queries
    Replies: 2
    Last Post: 03-21-2013, 08:45 AM
  4. Parent Item / Child Item Not Saving Correctly Together
    By Evilferret in forum Programming
    Replies: 6
    Last Post: 08-24-2012, 02:30 PM
  5. Replies: 7
    Last Post: 10-25-2011, 08:32 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