November 28, 2012 at 10:04 pm
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.
November 29, 2012 at 4:47 pm
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
November 30, 2012 at 12:42 pm
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.
November 30, 2012 at 12:50 pm
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 30, 2012 at 1:13 pm
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
November 30, 2012 at 1:22 pm
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?
November 30, 2012 at 1:32 pm
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 30, 2012 at 1:43 pm
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?
November 30, 2012 at 1:57 pm
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 30, 2012 at 2:52 pm
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
November 30, 2012 at 3:12 pm
sasansamani (11/30/2012)
SELECT DMax("[AssetNumber]","Waste Hauler Number","+1") AS Expr1 FROM [Waste Hauler Number];I am getting two 4001. What I am doing incorrectly?
The last parameter is the criteria (it acts like a where clause). "+1" is not valid there.
Personally I hate those built in functions. I find them obtuse and difficult to read.
I would write that as a query instead.
select MAX(AssetNumber) + 1 from [Waste Hauler Number]
_______________________________________________________________
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 30, 2012 at 3:20 pm
thank you very much. It works now.
I tried to use something simlar to that.
November 30, 2012 at 3:30 pm
You're welcome. Glad that worked for you.
_______________________________________________________________
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
December 1, 2012 at 3:30 am
Hi
My apologies for not being able to contribute to this earlier - I'm fairly certainthat I am in a different time zone to you.
If you are wanting to do this in an Access query, then you could use a LEFT OUTER join. Join the table with the incrementing number to the table you wish to check via the two number attributes, then set the join type to the left outer join option (2).
If you create a test query in this way (Important Note: drag your join from the table with the incrementing number to the table you wish to check) and simply add the two attribute, you will see matching numbers where you have used the number and the incrementing number and a null in the cases where the numbers haven't been used.
Taking this a step further, add a null criteria for the attribute in the table you are checking, and you will be returned a set of numbers that haven't been used. You could then use this as a subquery for generating the next unused number by changing the query to a group (aggreagte) query and use the min option.
Cheers
Rowan
December 1, 2012 at 4:01 pm
thank you everyone
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply