473,387 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

codify products

mseo
181 100+
hi,
I need to know if i can give each product unique code depending on the category and sequence number other than PK field
in other words, the sequence of products in each category
for example
dairy-001
cheese-001
milk-002
Vcheese-002

thank you very much
Aug 4 '10 #1
6 1788
mseo
181 100+
can I codify products?
Aug 6 '10 #2
NeoPa
32,556 Expert Mod 16PB
You can, but you'll need to make the question details clearer before I can direct you how. Your example data makes little sense to me. Please explain.
Aug 6 '10 #3
missinglinq
3,532 Expert 2GB
I have to agree with NeoPa, the exemplar data does nothing toward explaining what you're trying to accomplish!

Linq ;0)>
Aug 7 '10 #4
mseo
181 100+
hi,
I have a ProductID (AutoNumeber)field and it seems meaningless for the user so I added one more field and I need to fill this field as the following:
each product has category so I need to codify the products using first four characters from the category name and concate it with a number
the problem I need this number to be generated automatically, and grouped by categoryID
let's assume I have two Categories :
1- dairy
2- Oil
and more than one products I need to generate the code for each product to be like that
Expand|Select|Wrap|Line Numbers
  1. Product    Code
  2. Milk       DAI-0001 
  3. IceCream   DAI-0002
  4. Olive      OIL-0001
  5. Butter     OIL-0002
  6.  
so,characters reflect the Category, and numbers reflect the sequence of the product in each category

I really appreciate your help
thank you very much
Aug 8 '10 #5
rwalle
47
Hi Mseo:

I Have done a small Hardware store DB that store Products , customers , suppliers, etc,the products have several categories I set the table like

Pk : Autonumber
ProdType: FK( Cbox to choose from TypeTbl that stores values like. "Electric","Plumber","Garden","Construction", . . Etc.)
Supplier:FK (ComboBox to choose from SuppTbl)
PartNum:Text which I format to be like "01-02-003"
that stands for: (01: Product type); (02: Supplier);(003:serial number)
The user who "create" new Products should know the product codification logic, so He can input right way,
then the users that just use the Db to invoice products or make inventory transactions can have clues about what to input into search forms

I hope this can be help you

Raymundo Walle
Aug 8 '10 #6
NeoPa
32,556 Expert Mod 16PB
First of all, you need a field that identifies the category. From this, there must be a way of determining your three-character stub.

You would also need a form to enter this data in. For simplicity we'll start with a form that has the three simple controls - [txtCode], [txtCategory] & [txtProduct].

Now, an important point is that you cannot guarantee the value of the code until it has been saved. We can create a DefaultValue for the control if you like, but this may not reflect the actual value used, so you may prefer not to set a default at all. Your choice.

The important code, that can be run to set the DefaultValue, but must be run from within Form_BeforeInsert, will determine the correct value at that specific point in time using the category from [txtCategory].

This code will use DMax() to find the max numerical value attached to any record of the matching category. It will take this value, or 0 if no value found, then add 1 to it and append it to the category stub to form the new [txtCode].
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeInsert(Cancel As Integer)
  2.   If IsNull(Me.txtCategory) Then
  3.     Call MsgBox("No Category selected")
  4.     Cancel = True
  5.     Exit Sub
  6.   End If
  7.   Me.txtCode = NextCode(Me.txtCategory)
  8. End Sub
  9.  
  10. Private Function NextCode(strCategory as String) As String
  11.   Dim intMax As Integer
  12.  
  13.   intMax = Val(Right(Nz(DMax("[code]", _
  14.                              "[ProdTable]", _
  15.                              "[Category]='" & Me.strCategory & "'"), 0), 4))
  16.   NextCode = UCase(Left(strCategory, 3)) & "-" & Format(intMax + 1, "0000")
  17. End Function
Aug 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: frizzle | last post by:
Hi there I have a products site with a mysql backend. I have two tables: 1 with series, 1 with products belonging to certain series. Series looks like: - id - kind
0
by: Ralph Guzman | last post by:
TASK: I have to generate a report with all categories, subcategories and products in database. PROBLEM: I want to write one query that will return: 1. category 2. subcategory: determined by...
2
by: Hohn Upshew | last post by:
I need some help to build a report enumerating the products in descending order depending on the sum of liters. In this way i can view the top products sold for a given period.But i fail to do...
1
by: Mark | last post by:
My Category and Product tables look like: TblCategory CategoryID Category TblProduct ProductID CategoryID Product
6
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from...
2
by: TD | last post by:
I have this expression in the criteria section of a query: IIf(Forms!frmReports!cboProductID="<ALL PRODUCTS>",. Like "*",Forms!frmReports!cboProductID) (the syntax of the above expression may...
24
by: Rob R. Ainscough | last post by:
I was reading yet another book on .NET - VB 2005 Professional (wrox) and read the statement; "Microsoft has staked their future on .NET and publicly stated that henceforth almost all their...
9
by: Earl | last post by:
I have somewhat of an interesting scenario: The form allows the user to select a service, which populates a a grid of product information related to that service ("service grid"). The user can...
0
by: shapper | last post by:
Hello, I am displaying a list of products. I created a model using Linq To SQL. The List method is as follows: public void List(int? page) { dt.Products = (from p in db.Products orderby...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.