Results 1 to 5 of 5
  1. #1
    Stika is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    18

    Dmax to create unique ID

    I have a form with a combobox where I select the Carrier witch then populates a multiselect listbox with all the record from that carrier in the specified date. When I select them and click save I want all the record ID(ConID) saved under the same ID(manifest ID) ie,



    1 223
    1 225
    2 344
    2 4444
    Ect

    It saves it in a table called Manifest With the fields Manifest ID and CONID which is a lookup field to a different table

    here is my current code for the on click command

    Code:
    Dim db            As DAO.Database
        Dim rs            As DAO.Recordset
        Set db = CurrentDb()
        Set rs = db.OpenRecordset("Manifest", dbOpenDynaset)
        
        If List21.ItemsSelected.Count = 0 Then
            MsgBox "No Consignment notes selected"
            GoTo Endme
        End If
        
        If IsNull(Combo17.Value) Then
            MsgBox "No Carriers were selected"
            GoTo Endme
        End If
          
        
            For Each row In List21.ItemsSelected
                Conidval = List21.Column(0, row)
                rs.AddNew
                rs!ConID = Conidval
                rs.Update
            Next
    
    
    Endme:
    End Sub
    Now ive done some searching and I thin dmax is what I want to use...but im not sure how to make it work

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    Why do you think DMax is needed? You want to determine the maximum ManifestID in the table and increment it for use in this procedure?

    ConIDval = DMax("ManifestID", "Manifest") + 1
    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
    Stika is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    18
    Well im not sure whats needed...I want it to generate a ManifestID number...I thought DMax was the command to do it, But I dont think that works

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    DMax will retrieve the maximum value of the ManifestID field. Then the calculation would increment it to the next number, assuming ManifestID is a numeric field. Then use that calculated value to populate field of the new Manifest record.

    Why not use the Autonumber field to automatically generate ManifestID?

    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
    Stika is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    18
    I Tried that code but what it is outputting in the table is

    1 772
    2 882
    3 776

    But Instead I want
    1 772
    1 882
    1 776

    So autonumber field isnt an option cause I want to be able to drag those details out later for a report by Manifest ID

    I Found a Solution today I put that Dmax Code into a text box and It works exactally how I want it to.

    Thanks for you help

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

Similar Threads

  1. Replies: 6
    Last Post: 07-24-2012, 03:02 PM
  2. Unique queries - Unique Count
    By bigfish in forum Queries
    Replies: 7
    Last Post: 03-14-2012, 01:28 PM
  3. Create a unique report
    By top1hat19 in forum Reports
    Replies: 1
    Last Post: 01-31-2011, 12:42 PM
  4. Multiple options to create semi-unique letters
    By GenericHbomb in forum Import/Export Data
    Replies: 0
    Last Post: 07-27-2010, 08:46 AM
  5. How to create and print unique report for each entry???
    By Stelios Panayides in forum Reports
    Replies: 2
    Last Post: 10-05-2009, 08:54 AM

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