Hi Mari,
Since the XX is constant, you should not store it, as the others said.
Also, while Access allows it, Number is not a good name for a field. Rather
use something like ItemNumber. Number can get misinterpreted. Do a search
in your online help for "reserved words" to see the ones that are better to
avoid.
Anyway, in your code for adding new items, do something like this
(untested):
Dim intIndex As Integer
Dim intNewNumber As Integer
intNewNumber = Nz(DMax("[Number]", "[your item table]"), 0) + 1
DoCmd.SetWarnings False
For intIndex = 1 To [Quantity]
DoCmd.RunSQL -
"insert into [your item table] ([Number]) values (" & intNewNumber &
")"
intNewNumber = intNewNumber + 1
Next intIndex
DoCmd.SetWarnings True
Me![subformname]![Form].Requery
If you have other required fields in your item table, you will have to
supply those field names and some values for them also inside of the
parantheses, separated by commas.
Hope that helps,
Clifford Bass
Mari said:
The table is a simple sub table attached to the main table of items.
Main Table-information on the item
Sub Table - Has the list of numbers that have been issued
The "XX" in the beginning does not change because it is the item ID tag.
Clifford Bass said:
Hi Mari,
You will need to store the results somewhere. And then before
generating the numbers you will need to check to see what value was last
used. Added questions: What is the table where you are storing the new
values? If you have an item DEF, does it also get assigned the XXnnnn? Or
does it get assigned YYnnnn?
Clifford Bass
:
Dim stCount As String
stCount = [Quantity]
Do While stCount > 0
Me![Number] = [Number] + 1
stCount = stCount - 1
Loop
But one of the major problems with this is it does not hold the number from
a previous record. This would just start it over everytime.