473,480 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Generating a Part Number

17 New Member
I’m trying to generate a part number of sort. It must be a total of 11 characters and have two “sections” separated by the letter ‘P’. The first section is a number I select from a combo box and can consist of 1 to 6 characters in length. The second section must be a unique incremental number starting from 1 that will have leading zeros to make up the total 11 character part number. It would look something like this: 0000P000000. Any help?
Apr 19 '07 #1
4 2167
Denburt
1,356 Recognized Expert Top Contributor
I’m trying to generate a part number of sort. It must be a total of 11 characters and have two “sections” separated by the letter ‘P’. The first section is a number I select from a combo box and can consist of 1 to 6 characters in length. The second section must be a unique incremental number starting from 1 that will have leading zeros to make up the total 11 character part number. It would look something like this: 0000P000000. Any help?
ok is your combo box set up and ready to go?

What are your field names?

Output:
Me!MytextOut

Combo Box:
Me!MyBox.column(0)

My AutoNumber:
Me!MyAutoNumb

Me!MytextOut = Me!MyBox.column(0) & "P" & Me!MyAutoNumb


There are a number of ways to auoto generate an id number and I will try to get back to this soon.
Apr 20 '07 #2
rousseaud
17 New Member
ok is your combo box set up and ready to go?

What are your field names?

Output:
Me!MytextOut

Combo Box:
Me!MyBox.column(0)

My AutoNumber:
Me!MyAutoNumb

Me!MytextOut = Me!MyBox.column(0) & "P" & Me!MyAutoNumb


There are a number of ways to auoto generate an id number and I will try to get back to this soon.
Thanks for the reply. I do have a combo box setup. There is one field beside the ID, called Product. The field in another table that I want to store the Part Number is called PartNumber. I would appreciate any help you could provide. Thanks
Apr 20 '07 #3
Denburt
1,356 Recognized Expert Top Contributor
Thanks for the reply. I do have a combo box setup. There is one field beside the ID, called Product. The field in another table that I want to store the Part Number is called PartNumber. I would appreciate any help you could provide. Thanks
Not sure if I understand everything, you are storing the products in one table and the part number in another correct?

If this is the case then this should work.
Expand|Select|Wrap|Line Numbers
  1. Dim strVar as string, str0 as string
  2. Dim inInt as integer
  3. strVar = Me!MyBox.column(0) & "P" & Me!MyAutoNumb
  4. inint = len(strVar)
  5. if inint<11 then
  6. Do untill inint = 11
  7. str0 = str0 & 0
  8. strVar = Me!MyBox.column(0) & "P" & str0 & Me!MyAutoNumb
  9. inint = len(strVar)
  10. loop
  11.  
  12. Docmd.runsql("insert into PartNumberTable (PartNumber) VALUES ('" & strVar & "'))
  13.  
Apr 20 '07 #4
rousseaud
17 New Member
Thanks! This is a big help. I had some trouble with the SQL in the last line and changed it a bit. Here's what I ended up using:

Dim strVar As String, str0 As String
Dim inInt As Integer
strVar = Me!MyBoxP.Column(0) & "P" & Me!MyAutoNumb
inInt = Len(strVar)
If inInt < 11 Then
Do Until inInt = 11
str0 = 0 & str0
strVar = Me!MyBox.Column(0) & "P" & str0 & Me!MyAutoNumb
inInt = Len(strVar)
Loop

End If

Me.PartNumber = strVar
Apr 20 '07 #5

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

Similar topics

0
1777
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # David Eppstein of the Geometry Junkyard fame gave this elegant # version for returing all possible pairs from a range of n numbers. def combo2(n): return...
17
2111
by: flupke | last post by:
Hi, i create my GUIs mainly via wxGlade. However when you start of to program and want to do some rearranging to the gui, wxglade overwrites your file and you've got to put your own code back...
4
3005
by: Justin Lebar | last post by:
Sorry about the huge post, but I think this is the amount of information necessary for someone to help me with a good answer. I'm writing a statistical analysis program in ASP.net and MSSQL7 that...
7
1862
by: Eddie | last post by:
I searched with my problem but with no results :( My question is: how can I generate string, having only simple pattern, like, midend For example tyis pattern should reproduce strings like: ...
6
5524
by: Poul Møller Hansen | last post by:
I have made a stored procedure, containing this part for generating a unique reference number. SET i = 0; REPEAT SET i = i + 1; SELECT RAND() INTO reference FROM SYSIBM.SYSDUMMY1; SET...
13
1539
by: vasudevmukherjee | last post by:
Hi! Can somebody help tell me why the following code gives a garbage value while producing first student's name, whereas it gives the names correctly for other three students - I really fail to...
7
3983
by: Gerard Flanagan | last post by:
All would anyone happen to have code to generate Cutter Numbers: eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm or is anyone looking for something to do?-) (I'm under...
3
1852
by: jszczepankiewicz | last post by:
Witam, mam nastepujacy problem: XSLT 2.0, Hi, i've got following problem with xslt 2: my xml doc looks something linke: <manual>
7
3902
by: horacius.rex | last post by:
Hi, I want to profile a C program I am writting, so I compile it with -pg options and use gprof to obtain information about call graphs, which I am really interested in. I look at the text files...
0
7054
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
6918
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...
1
6756
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...
0
7003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5357
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3008
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.