Results 1 to 6 of 6
  1. #1
    normie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    53

    auto enter sequential numbers

    Ineed to track Trailer security seals that are sequentially numbered with 8 digit numbers...They are physical seals and no efile with the numbers to upload into Access...is there a way I can put in a range and Access will populate the rest in a table?

  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    You need to give some more data, what is your table structure? What are you trying to achieve?

    For instance I'm guessing you have a database to track which seal is placed on each trailer.

    Example 1. You have a new roll of these seals and want to import a list of the numbers to access, and then allocate them individually

    Example 2. You have a list of them already in place, and want to update the trailers that they are physically attached to?

    Each one could potentially be what you are asking but I would give a different response to.

  3. #3
    normie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    53
    Thank you for your reply the first example is what I am looking for:Example 1. You have a new roll of these seals and want to import a list of the numbers to access, and then allocate them individually
    I get the numbers off the actual seals There are 100's and was hopeing to enter some kind of range and have the rest filled in....The table has two columns 1) the seal number and 2) the department that recieved the allotment...So I would give one department 125 seals and would need that department filled in beside the corresponding seal numbers should Customs come for an audit..( they would look at the list and then physically look for the seals)....Matching with the trailer number will just be a query against theis table and the table that holds the trailer numbers

    I hope I have explained this clearly

    Thanks again

  4. #4
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Right that makes sense and its actually easier than I thought it was going to be!

    Right the easiest way I can think of doing this is with a little visual basic.

    In this instance I will assume the following table structure is used


    Tbl_seals Tbl_Department

    SealID (field is a number) DepartmentID
    DepartmentID Department

    Create a query and put the all the fields except departmentID in Tbl_department above in it (ensure a relationship is made between departmendID's), call it qry_New-seals

    Create your form and in the detail put sealID and DepartmentID boxes (called txt_sealid and txt_Departmentid) and set your form to continuous forms.

    In the form header put an unbound combobox with the recordsource being Tbl_Department (call it cbo_department,2 columns, columnswidths 0cm,3cm), a textbox (call it txt_sealmin), another textbox (call it txt_sealmax), and add a commandbutton (cmd_addseals).

    then right click the command button, build event, code builder.

    Then in the event procedure (between Private sub Cmd_addseals_Click() and End Sub, but i have included these for Clarity) put:

    Private Sub Cmd_addseals_Click()
    'declare variables
    dim sealrange as integer
    'checks to see if all the fields are filled
    if isnull([cbo_department]) or isnull([txt_sealmin]) or isnull([txt_sealmax]) then
    msgbox "please input into all boxes"
    elseif [txt_sealmin]>[txt_sealmax] then
    msgbox "Seal min is greater than seal max!"
    else
    'add the new seals
    sealrange =[Txt_sealmax]-[Txt_sealmin]
    for x=0 to sealrange
    docmd.gotorecord acactivedataobject, , acnewrec
    [txt_sealid] = [txt_sealmin]+x
    [txt_departmentid]=[cbo_department]
    next
    msgbox "seals added and allocated!"
    endif
    end sub

    Sounds long and hard but I'm building an example to simplify it!

    Click the button with the fields filled in and it should work.

    ---End of wall of text---

    Edit: uploaded example
    Attached Files Attached Files
    Last edited by R_Badger; 04-02-2012 at 10:04 AM. Reason: Uploaded example

  5. #5
    normie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    53
    Success!!! Thanks for your help It turned out to be exactly what I needed... You said it was easy ..well maybe for your knowledge levl but mine not so much
    Cheers!!!

  6. #6
    fehenry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    1
    this is helpful but how would modify the code to place sequential numbers in a field for existing records as they are currently sorted? Thanks

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

Similar Threads

  1. To generate sequential numbers in query
    By lizzywu in forum Programming
    Replies: 1
    Last Post: 03-02-2012, 12:01 PM
  2. Replies: 11
    Last Post: 07-14-2011, 03:03 PM
  3. How to add sequential numbers to query resultset
    By h_latha2k in forum Queries
    Replies: 3
    Last Post: 04-29-2011, 08:53 PM
  4. Renumbering Auto-Increment numbers
    By svcghost in forum Database Design
    Replies: 8
    Last Post: 02-19-2011, 08:48 AM
  5. Replies: 3
    Last Post: 10-18-2009, 08:38 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