Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Incremental Number Expand / Collapse
Author
Message
Posted Wednesday, November 28, 2012 10:03 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
lets say I want to increment 0000 to 9999. I know how do this.

how would you identify if I have used that number?

How would you tell the field in the form to populate the numbers you haven't used?

I guess my second question and third question are related.
Post #1390273
Posted Thursday, November 29, 2012 4:47 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 21, 2014 4:34 PM
Points: 48, Visits: 9,470
Hi

I'm sorry to answer your questions with a question but we need to know what method you are using to increment from 0000 to 9999.

If you are using an auto increment data type (that is incrementing by 1) then the answer is simple - use a max (query) or dmax (VBA) function. If you are using code to do it and the numbers aren't sequential then it gets more complex.

The answer will also depend on whether you are attempting to do this in a query or VBA.

Cheers

Rowan
Post #1390913
Posted Friday, November 30, 2012 12:42 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50

how would you identify if I have used that number?

How would you tell the field in the form to populate the numbers you haven't used?


I would like to this in a query.
Post #1391511
Posted Friday, November 30, 2012 12:50 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:36 PM
Points: 13,111, Visits: 11,946
If you are using an autonumber you are going to have gaps. This is perfectly normal. Honestly, why does it matter if there are gaps?

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391517
Posted Friday, November 30, 2012 1:13 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
Actually my autonumber starts at 1000. You are right. How do I automatically assign random numbers for a 4 or 5 digit number? How do I determine if I have used that number before in the table?

00000-V/C 0000- AT-YR

Post #1391531
Posted Friday, November 30, 2012 1:22 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
Basically what I am doing is I am parsing 0000-V/C 0000-AT-YR and then putting each section into its field in a table. I need to know how I can determine if that asset number have been used before? If that number has nerver been used then it needs populate into the form field called Asset.

In other words, How do I validate against another table? Do I use DCount Function?
Post #1391537
Posted Friday, November 30, 2012 1:32 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:36 PM
Points: 13,111, Visits: 11,946
sasansamani (11/30/2012)
Actually my autonumber starts at 1000. You are right. How do I automatically assign random numbers for a 4 or 5 digit number? How do I determine if I have used that number before in the table?

00000-V/C 0000- AT-YR



If it is an autonumber you don't. That is the point of it being automatic...you don't have to do anything.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391539
Posted Friday, November 30, 2012 1:43 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
I made myself confused and you. I need more coffee. I thought you were referrring to another field.

Right now my problem is how do I validate against another table? How do I tell the form field to show me numbers I havent used before?
Post #1391543
Posted Friday, November 30, 2012 1:57 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:36 PM
Points: 13,111, Visits: 11,946
sasansamani (11/30/2012)
I made myself confused and you. I need more coffee. I thought you were referrring to another field.

Right now my problem is how do I validate against another table? How do I tell the form field to show me numbers I havent used before?


MAX(Field) + 1 ???


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391550
Posted Friday, November 30, 2012 2:52 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
SELECT DMax("[AssetNumber]","Waste Hauler Number","+1") AS Expr1 FROM [Waste Hauler Number];

I am getting two 4001. What I am doing incorrectly? I have 4000 and 4001
Post #1391565
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse