Page 1 of 1

Complex Product Code

Posted: Mon Mar 05, 2012 7:03 pm
by ruiascensao
Hi,

I'm trying to build a warehouse aplication. One product is identified by two codes from diferente tables:
Example: 00123 345

00123 is the palet number
345 is a unit in the palet

How can I do this using the auto increment?

Thank You!

Best Regards,
Rui

Re: Complex Product Code

Posted: Thu Mar 08, 2012 1:53 am
by admin
Rui,

The simple answer is don't use auto-increment.

Why do you want to?

Steven

Re: Complex Product Code

Posted: Sat Mar 10, 2012 1:54 pm
by ruiascensao
Hi Steven,

If I don't use auto-increment.
How can I do this?
In the image attached I send you one example:
1 - Wharehouse code
10 - Customer Code
0000101 - Pallet code
122 - Unit code (unit that is in the pallet )

So for diferent wharehouses I can have the same pallet number and unit number.
But the Job Number it is always diferent.

Any ideia?
Regards,
Rui

Re: Complex Product Code

Posted: Wed Mar 14, 2012 4:57 pm
by admin
Whenever you use and auto-increment field it must be the primary key
Don't use auto-increment primary keys http://nubuilder.blogspot.com.au/2010/0 ... -keys.html



If you go to our current demo http://demo.nubuilder.com/db/samplenufinancial/ you will see how we create invoice numbers (go to Invoices).

If you go to the properties of Invoice Number..

In SQL Run Before Display You will see..

Code: Select all

INSERT INTO next_number SET nxn_key = '#TT#'

Then on the Text Tab
Default Value SQL you will see..

Code: Select all

SELECT next_number_id FROM next_number WHERE nxn_key = '#TT#'
All this uses a table created like this..

Code: Select all

CREATE TABLE IF NOT EXISTS `next_number` (`next_number_id` int(11) NOT NULL AUTO_INCREMENT,
`nxn_key` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`next_number_id`));
This is the only time we use auto-increment (in a separate table) just to
generate a sequential number.

I hope this makes sense.

Steven

Re: Complex Product Code

Posted: Thu Mar 15, 2012 9:26 am
by ruiascensao
Hi Steven,

Thank you!
I see now how to use that code!
But I don't now how to use it to solve my problem.
Can you help me?

Best Regards,
Rui

Re: Complex Product Code

Posted: Fri Mar 16, 2012 2:03 am
by admin
Rui,

Don't rely on a Primary Key to be your job number.

Create another field and use that to hold a job jumber.

And apply the code for generating a new number to that field.

If that still doesn't help, then I don't understand what your problem is.

Steven

Re: Complex Product Code

Posted: Fri Mar 16, 2012 9:14 am
by ruiascensao
Hi Steven,

It helps! But following the example how can have:
Job Number: 1 10 0000101 122 and Job Number : 2 11 0000101 122
1 - Wharehouse code
10 - Customer Code
0000101 - Pallet code
122 - Unit code (unit that is in the pallet )

With your help now I know how to create the warehouse code / Customer Code / Pallet Code / Unit Code using tables.

The problem is ... how can I have the same Pallet Code in two diferente wharehouses (but the pallets are not the same)?

Thank You!

Best Regards,
Rui

Re: Complex Product Code

Posted: Wed Mar 21, 2012 11:17 pm
by admin
Rui,

That's like saying how can there be a person called "Bob" in 2 different countries, when they are not the same person.

I don't understand why that is a problem.

If you have to need to search for something sometimes you need to filter on more than one field.

eg.

Name AND Country

Pallet AND Warehouse.

Steven

Re: Complex Product Code

Posted: Wed Mar 28, 2012 4:13 pm
by ruiascensao
Hi Steven,

The problem is that I don't now how to do it.

Can you please help me?

Best Regards,
Rui

Re: Complex Product Code

Posted: Thu Mar 29, 2012 3:26 am
by admin
Rui,

I take it you know how to add fields like

Name AND Country AND Pallet AND Warehouse.

to an Edit Form.

So just add them to the Browse Form as well and you'll be able to find any record you need by typing what you are looking for in the Browse's Search Field.

1:10 into this tutorial you will be shown how to filter records. http://www.youtube.com/watch?v=1B-xz4Bf ... ure=relmfu

Steven