Results 1 to 5 of 5
  1. #1
    bps is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    3

    Making a column in existing table into an autocounter

    Hello, I started developing an Access database for my company and using the current database on excel as a basis for it.

    One of the main columns in our excel sheet is the catalog number for our products. However, with the new program we also want to auto-generate catalog numbers, and add it to list of existing products. The existing numbers are none sequential, so I was thinking of making the new cat numbers start from 100000.



    I have tried to create another table starting from 100000 and using UNION all to join the tables, but was wondering if there was a more efficient method to do this.

    Kind Regards!

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    You probably should post a picture of your relationships window if you have created relationships. The fact that you mention Excel and refer to Union queries as a means of joining tables makes me think you have gotten off on the wrong path when it comes to design. You should also state how important it is to have sequential numbers, and maybe more about the business case. I'm also wondering why you chose such a number design as 100589 as a product number since that won't tell you anything about it at all. Maybe that's OK for you.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    bps is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    3
    Business case: company has several excel sheets in the production line, one for each group. This leads to mis-communication between each group about time-frames and deadlines, so its a complete mess right now. They want to merge all the company's processes into one program that the whole company can see what is happening.
    I never have used Access before, and was tasked to start the process of creating this database (CEO is cheap...)

    It isnt necessary that the numbers to be sequential. But I am using the catalog numbers as a primary key to link it with the rest of the information in the database, as on the relationships image below.

    Click image for larger version. 

Name:	Access Relationships.JPG 
Views:	10 
Size:	65.1 KB 
ID:	28491

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    Looks better than I had imagined. Usually, when someone posts certain keywords the immediate impression is that the db has been designed with a spreadsheet mentality. Not knowing the terms in the tables, I think that the approach ought to be tbl_Purification.Catalog Number linked to Main_Proteins, then to cloning as you have it. I don't see Catalog Number being needed in tbl_Purification if you do this; in fact having it in both tables might prove to be promlematic. By not using the record id's (e.g. MainProteins.ID on ProteinDatabase.MainProteins_FK) you could be faced with an update dilemna. Should you ever need to change a catalog number, you will have to cascade update that number throughout the entire db. You may have addressed this via the relationships but I don't see it (more on what I see below after the quoted text).

    Aside from that, having special characters (save the underscore) in names is frowned upon (you have at least 5 types), as is having spaces in names. Units (mg) are unnecessary as well. The form label should be the identifier for units if needed. Having said that, you might want to consider tblUnits from which users specify when entering data. That can be added later if it becomes more attractive than it probably is now.

    I am using the catalog numbers as a primary key
    If by that you mean Parent_Catalog_Number, then on my laptop it looks like the joins are going the wrong way, but I'm not sure. It does not look like they are PK's anywhere else, so that's my guess. Your Access version is ahead of mine, thus how the joins are represented might be the cause for an incorrect guess on my part. Also, database is a reserved word and should not be used as a db object name. See http://allenbrowne.com/AppIssueBadWord.html and https://access-programmers.co.uk/for...d.php?t=225837

    There are a few ways to accomplish sequential numbering; just don't do any of them in the table itself. The main consideration is whether or not you can foresee concurrent users creating a record more or less at the same time. I presume you have or will split the db, which makes this more probable than not. Then the issue comes down to when to create the catalog number - at the beginning or end of a record creation process. At the beginning, you run the risk of two or more users creating the same number concurrently, and the last one to save the record gets a write conflict error. At the end, you eliminate that, but can be faced with not having related records in other tables at the moment that number is saved, assuming you have designed things that way. If the record is canceled/deleted, you end up with gaps, which you've already stated is OK. More details about the user environment would be useful for us to suggest the more favorable approaches.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849

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

Similar Threads

  1. Making a labeling column with Sequential Numbers
    By Darth_Elicious in forum Queries
    Replies: 8
    Last Post: 04-12-2017, 11:00 AM
  2. Replies: 8
    Last Post: 08-31-2016, 07:55 AM
  3. Insert Column between existing columns?
    By JC8865 in forum Access
    Replies: 2
    Last Post: 12-06-2014, 09:05 PM
  4. Replies: 5
    Last Post: 04-30-2012, 11:03 AM
  5. Replies: 7
    Last Post: 02-06-2012, 11: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