473,386 Members | 1,795 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,386 software developers and data experts.

Generate Sequential numbers for new records

I am developing a Work Order Database for my job. I have a combo box with "Contract Numbers" to select from. When you select on any Contract Number I need a new "Work Order Number" to appear. There are 10 different contract numbers so I need 10 different work order numbers (N10001, O100001, etc..) to generate sequential for each new record.
Jun 20 '07 #1
6 6946
hyperpau
184 Expert 100+
I am developing a Work Order Database for my job. I have a combo box with "Contract Numbers" to select from. When you select on any Contract Number I need a new "Work Order Number" to appear. There are 10 different contract numbers so I need 10 different work order numbers (N10001, O100001, etc..) to generate sequential for each new record.
That is easy and I can answer this question. but you need to
give me the specifics. Where is the combobox with Contract numbers bound?

is this a Primary key for another table?

Tell me how many forms you have and what format you want
to put for you Work Order Number.
Jun 20 '07 #2
That is easy and I can answer this question. but you need to
give me the specifics. Where is the combobox with Contract numbers bound?

is this a Primary key for another table?

Tell me how many forms you have and what format you want
to put for you Work Order Number.
This is my layout.

tblcompanies
PK - CompanyID
tblcontractlist
PK - Contract NUmbers (this is where I have my combo box)
- Company ID
tblMaintWO
PK - MaintWorkorderID
- Contract Numbers

Right now I have one form (FrmMaintWO).

I want to select a contract number from the combo box. This should automatically bring up a new work order number for that specific contract number

example:
A0009041E - (Work Order Num) E100001, E100002, E100003
A0009041G - G100001, G100002

Also, I would like to see the Work Order Numbers stored in a Combo So I will see the Work Orders that have already been entered.
Jun 21 '07 #3
hyperpau
184 Expert 100+
This is my layout.

tblcompanies
PK - CompanyID
tblcontractlist
PK - Contract NUmbers (this is where I have my combo box)
- Company ID
tblMaintWO
PK - MaintWorkorderID
- Contract Numbers

Right now I have one form (FrmMaintWO).

I want to select a contract number from the combo box. This should automatically bring up a new work order number for that specific contract number

example:
A0009041E - (Work Order Num) E100001, E100002, E100003
A0009041G - G100001, G100002

Also, I would like to see the Work Order Numbers stored in a Combo So I will see the Work Orders that have already been entered.

The way you gave me the information is vague but let me try that.
Which is the Work Order number, the one starting in A? or in E?
What is that number startin in G? It's so hard to understand it.

Assuming that the Work Order Num is the one startin in E,
this is how I understand it.
FrmMaintWO is bound to tblMaintWO.
tblMaintWO has the fields MaintworkorderID and Contract Numbers.
This Contract Numbers in TblMaintWO is a lookup combo box to
the Contract Numbers found in tblContractList.

Do i get this right?

Now, what you want to do is on the FrmMaintWO, you would select the
Contract Number from the combo box which looks up the Contract Numbers from the tblContractList.
What you want to happen is that, as soon as you select the contract number for the combo box, it would generate a Work Order for that specific contrace number.

If i get this right, this is how you do it.

1. On tblMaintWO, you must add 2 additional fields.
1st field is labeled WOID which is a number: long integer.
2nd field is labeld WONumber which is a text field.

2. On FrmMaintWO, drag and drop down the two new fields on
your desired location.
The WOID field should be set to Visible=No on the properties.
The FrmMaintWO should also be set to the properties:
Allow Additions = Yes
Data Entry = Yes

Add VBA coding to the AfterUpdate Event of the ContractNumber combo box.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ContractNumber_AfterUpdate( )
  2.  
  3.     Me!WOID  = Nz(DMax("WOID", "tblMaintWO"), 0) + 1
  4.     Me!WONumber = "E10" & CStr(Format("[Me!WOID]", "0000"))
  5.  
  6. End Sub
as soon as you select a Contract number from the combo box of
FrmMaintWO, the WONumber text box generates a sequential number
in this format: E100001
I dont know how to underline the last 4 digits.


Regarding saving the WONumber in a combobox, I don't understand your
question. Where would this combo box be placed on? Woudl this be on the
Same FrmMaintWO?
Jun 25 '07 #4
I apologize for the vague description. I am new to access so a lot of things I do not understand yet.

Yes you are correct except in the code on line 4 you are only identifying "E10" for the work order number.


All my contract numbers (located in the tblcontractlist) have the same format except the last letter changes.

When I click on contract numbers from the combo box, I can choose different contracts. A0009041A, A0009041B, A00009041C, etc.... When I choose a contract number, for example A0009041A, all the information for that specific contract comes up, company information, prices. etc.... the only thing I can not figure out is how to generate a specific "work order number" for each "contract number". The "work order number" should be the last letter of the "contract number" and "1" plus 4 zeros (A100001). So, every time I need to create a new work order for A0009041A a new "work order number" should appear for that specific contract number. Also, I would like if possible having another work order number field on my form which is a combo box to list all the previous work order numbers for that contract.



I hope I described it a little better.... Thank you so so much for trying to help.
I look forward to your response:)
Jun 26 '07 #5
hyperpau
184 Expert 100+
I apologize for the vague description. I am new to access so a lot of things I do not understand yet.

Yes you are correct except in the code on line 4 you are only identifying "E10" for the work order number.


All my contract numbers (located in the tblcontractlist) have the same format except the last letter changes.

When I click on contract numbers from the combo box, I can choose different contracts. A0009041A, A0009041B, A00009041C, etc.... When I choose a contract number, for example A0009041A, all the information for that specific contract comes up, company information, prices. etc.... the only thing I can not figure out is how to generate a specific "work order number" for each "contract number". The "work order number" should be the last letter of the "contract number" and "1" plus 4 zeros (A100001). So, every time I need to create a new work order for A0009041A a new "work order number" should appear for that specific contract number. Also, I would like if possible having another work order number field on my form which is a combo box to list all the previous work order numbers for that contract.



I hope I described it a little better.... Thank you so so much for trying to help.
I look forward to your response:)
I am not aware that there is a way to generate sequential letters like what you want. Generating the last letter from A-Z might not be possible.
the first letter which is the last letter of the contract number means you have to truncate. There is a way but i do not know how. As far as i remember, you should use a wild card (ex: Like "%A").

The only choice you have is to have those work ordernumber manually typed.
I apologize, I am not that advanced yet.
Jun 26 '07 #6
Thank you for trying.
Jun 27 '07 #7

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

Similar topics

6
by: Jenn L | last post by:
I have a database that is pre-populated with sequential part numbers. As people reserve the parts I update a flag to show the # is no longer available. Now they want the ability to take out a...
5
by: Lapchien | last post by:
I have list of numbers in a table (originally from autonumber in a different database) from 1 to 1,000,000. The list is not in sequential order - there are loads of numbers missing. How can I...
14
by: amywolfie | last post by:
Hi All: I know this is simple, but I just can't seem to get there: I need to sort a table by a text field (txtDescription), then assign sequential numbers to the field SEQUENCE in table. ...
2
by: Chris Dunaway | last post by:
I have a web service which is accessed by a windows forms application. When the application submits a unit of work (a "job"), I want to return a job receipt or tracking number back to the...
2
by: John | last post by:
Hi I need to assign sequential invoice numbers to orders starting from the last highest number + 1. I have tried the following code; UPDATE Orders SET Orders. = DMax("","Orders")+1 WHERE...
19
by: eric.nave | last post by:
this is a slight change to a fequently asked question around here. I have a table which contains a "sortorder" column where a user can specify some arbitrary order for records to be displayed in. ...
4
by: Bruce | last post by:
Surely someone has done this before, and I am guessing there is a simple solution that is eluding me. I have a simple report based on a recordset. For each record there is a field (RecNum) that...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone...
9
by: Axxe | last post by:
I have searched high and low for cogent, well-explained coding to complete a project on which I have spent six months of work. I stumbled across something on this site that is close to what I...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.