Results 1 to 4 of 4
  1. #1
    sireesha is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    50

    count of collection records and also increment the value of collection number

    Hi,



    I have a master/child forms. in master form sale_id,collection notes are placed. and in child form all collection details like collectionnumber,date,etc.,
    child form look like datasheet view.
    when i select the record from the list depending on the sale_id all the collection records shown in datasheet view form.
    if no record is there ok. if more than one records are there in collections of sale_id.i need count of records in collection depending on sale_id
    and also if i select one row in collection, notes to be shown for that record when i clik on shownotes button.

    if more than one record in collection automatically it increment. how many collections for the sale_id. collection number would be increment.
    how and also show notes depending on collection number and sale_id.

    please help me as early as possible.

    thank you
    sireesha

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    txtRecordCount ' create a textbox with this name
    =Count(sale_id) ' set as control source

    If [Me.txtRecordCount] > 0 Then ' Place code where it needs to be
    [Me.sale_id] = [sale_id] +1
    End If


    Not sure I understand what you are after, but hope this helps.

  3. #3
    sireesha is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    50
    Private Sub COLLECTION_LINE_NO_gotFocus()
    Set myDBS = CurrentDb
    SQLString = "select Count('Collection_line_no') from oldtractor_collections where sale_id=" & Me.SALE_ID


    Set recSet = myDBS.OpenRecordset(SQLString, dbOpenDynaset)
    p = recSet.Fields(0)


    If Me.COLLECTION_LINE_NO.Value = "" And p = 1 Then
    Me.COLLECTION_LINE_NO.Value = 1
    Else
    p = p + 1
    Me.COLLECTION_LINE_NO.Value = p
    End If
    End Sub

    the row is increment but wherever i place the cursor because gotfocus. already saved record is changed to increment value. and if selected saleid contains no rows the collection number should start from 1 but it placed 2. i need newly entered record should be incremented already saved records not changed.suppose 3 records entered 1,2,3 when new record is entered it should be 4.

    manually entering the records collection no. sometimes collection number have duplicates entered so i want to use like this way but its not working.
    please help me

    thank you

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2002
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    It seems to me that you are telling it P=1 for no value but then p = p + 1 , which is it ? Conflicting code, You give p a value of 1 then also give it p + 1 and that is why you get a value of 2. To truly see what you are doing I would need to see the db, care to attach for evaluation?

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

Similar Threads

  1. Fields Collection
    By crowegreg in forum Programming
    Replies: 1
    Last Post: 06-02-2011, 05:13 PM
  2. Collection function
    By ATLANTA in forum Programming
    Replies: 2
    Last Post: 04-17-2011, 04:11 PM
  3. Data collection
    By ROB in forum Access
    Replies: 2
    Last Post: 11-06-2010, 04:18 PM
  4. Button Collection
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 10:21 PM
  5. Collection of Page Total
    By in forum Reports
    Replies: 1
    Last Post: 12-06-2006, 06:02 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