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

Number increase

I am trying to create a drawing register, each new drawing has a number that increases by one for each new drawing entered.
I can not seem to get either an update or number +1 to work correctly.
My number format is AAA000000 this is to be assign only when certain text fields have been filled in, if any easier a button could be created to issue said number.
The prefix letters remain the same on all drawings and the number is to increase by 1.
please help !
Jul 24 '07 #1
2 1770
damonreid
114 Expert 100+
What I did when I had a problem like this was to create a combo box with all the codes I needed. Eg:

AAA
AAB
AAC
AAD
AAE

When the picked a value from the combo box I used that on a query to select all of that type. (only AAA's say).
On AfterUpdate for the combo box I used the following code:

Expand|Select|Wrap|Line Numbers
  1.     Dim strProdCode As String
  2.  
  3.         If Me.NewRecord Then
  4.         strProdCode = Me.SectionCode.Value
  5.  
  6.             ' Increment the CodeNumber field by One, if field is Null, set as 0 then add 1
  7.             Me!CodeNumber = Nz(DMax("Right(Code,3)", "QueryName"), 0) + 1
  8.             'Customize the ID then attach the incremented CodeNumber
  9.             Me!Code = Me.SectionCode.Value & "-" & Format(Me!CodeNumber, "000")
  10.  
  11.         Else
  12.  
  13.             Me!Code = Me!Code
  14.         End If
This would give AAA-001 as the first value, AAB-001 as the frist value in that section and then AAA-002 ect.

You need to add a new field to your list (in my case CodeNumber) to work with the SectionCode for this to work.
Jul 24 '07 #2
What I did when I had a problem like this was to create a combo box with all the codes I needed. Eg:

AAA
AAB
AAC
AAD
AAE

When the picked a value from the combo box I used that on a query to select all of that type. (only AAA's say).
On AfterUpdate for the combo box I used the following code:

Expand|Select|Wrap|Line Numbers
  1.     Dim strProdCode As String
  2.  
  3.         If Me.NewRecord Then
  4.         strProdCode = Me.SectionCode.Value
  5.  
  6.             ' Increment the CodeNumber field by One, if field is Null, set as 0 then add 1
  7.             Me!CodeNumber = Nz(DMax("Right(Code,3)", "QueryName"), 0) + 1
  8.             'Customize the ID then attach the incremented CodeNumber
  9.             Me!Code = Me.SectionCode.Value & "-" & Format(Me!CodeNumber, "000")
  10.  
  11.         Else
  12.  
  13.             Me!Code = Me!Code
  14.         End If
This would give AAA-001 as the first value, AAB-001 as the frist value in that section and then AAA-002 ect.

You need to add a new field to your list (in my case CodeNumber) to work with the SectionCode for this to work.

Thanks!

but i just need to increase the number by 1, did'nt quite get how to do that.
Sorry but new to SQL but slowly getting there.
Jul 25 '07 #3

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

Similar topics

3
by: Ronan Viernes | last post by:
Hi, I have created a python script (see below) to count the maximum number of threads per process (by starting new threads continuously until it breaks). ###### #testThread.py import...
2
by: Do Park via SQLMonster.com | last post by:
Hello all, A software that connects SQL Server via ODBC uses 12 process at the same time when I look at the process info(panel). Is it possible to increase number of process (or thread) for a...
2
by: a.p.mews | last post by:
Hi I'm trying to build a database to hold a CD collection inputting to a Form. I enter the CD number - no problem there, but would then like to enter a track number AND increase that number...
8
by: S. HP | last post by:
How can I make a build number that increases for each build automatically in a ASP.NET project, as I used to have in VB 6.0 ? Regards, SAHP
3
by: Edwin New | last post by:
I need to increase the number of connections to PostgreSQL 7.2.1. I have tried changing the value of max_connections in Postgresql.conf. It was commented out (as are all other entries except...
3
by: Henrik Dahl | last post by:
Hello! In VS.Net 2003 it was easy to make the build number to increase automatically at each build. Therefore it was easy to ensure that only one assembly would get a certain build number. I'm...
2
by: masker | last post by:
I was on the web trying to find a javascript that would allow me to input a number on my website and have it increase by a given percentage every second. During my search I found the Earth...
4
by: tony curtis | last post by:
I have a list of order numbers and want to increase the last number used by 1 and store the latest number in a table. Autonumber does not work for me as all the data is in a table already. New...
5
by: HowHow | last post by:
I am using Access 2000. I have few tables with primary keys, for example, StaffID, OrgID, CourseID and BookingID. In order for me to recognize my IDs easily later, I want to set a fixed character in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.