E
Etta
To Ken and others who can help...
I tried to follow Ken's instructions (reprinted below) very carefully but I
did not get them to work for me.
Here's what I did:
First, I created the DocumentsIssued table with the following
fields: Form_Number (which I tried to link to my Forms#_Title table), the
StartNumber, EndNumber and NumberIssued. Then I created a DocumentsIssued
Form and on the NunberIssued column AfterEvent, I entered the script Ken so
kindly provided. As my Form Numbers are alpha /numeric, I added the quotes
around the value. I also added the formatting to get 00001 for the Start and
End numbers.
My results? The form does not show the Form Numbers and it shows 00000 as
the StartNumber, 0 as the EndNumber and 000 as the NumberIssued (I programmed
this field to allow only three digits). Did I miss a step? When I issue ddo
forms for the first time, how will Access know that the StartNumber is 00001
and the EndNumber is 00025, if 25 forms were issued?
Also, from what I've told you, can you tell why the Form_Numbers from the
Forms#_Title table are not appearing in my DocumentIssued form? (The numbers
do appear in the Forms#_Title table .
Thanks, again Ken -- and all others who respond -- for your help.
Etta
Response from Ken...
Lets assume your table is called DocumentsIssued and it includes columns
DocumentID, StartNumber, EndNumber as well as the column for the
NumberIssued. In the data entry form, in the AfterUpdate event procedure of
the control bound to the NumberIssued column look up the last number issued,
and add 1 to get the next starting number and the value of the number issued
control to get the next ending number, assigning the two values to the
StartNumber and EndNumber controls, like so:
Dim intNumberIssued As Integer
Dim strCriteria as String
strCriteria = "[DocumentID] = " & Me.[DocumentID]
intNumberIssued = Nz(Dmax("[EndNumber]","[DocumentsIssued]", strCriteria),0)
Me.[StartNumber] = intNumberIssued + 1
Me.[EndNumber] = intNumberIssued + Me.[NumberIssued]
This assumes DocumentID is a number data type. If it were text you'd need
to wrap the value in quotes:
strCriteria = "[DocumentID] = """ & Me.[DocumentID] & """"
To show the numbers with leading zeros set the Format properties of the
StartNumber and EndNumber controls to 00000.
The above assumes that each document is issued to one department only rather
than to more than one department with the same number sequence used for each,
i.e. each starting with 1 rather than, for instance, one department using 1
to 25 and another department 26 to 50 and so on. If repetition of the same
numbers for the same document issued to different departments were the case
then the table would need to include a column such as DepartmentID and this
would need to be included in the criterion when calling the DMax function to
get the last number issued to that department, e.g.
strCriteria = "[DocumentID] = " & Me.[DocumentID] & " And [DepartmentID] = "
& Me.[DepartmentID]
Again this assumes both are of number data type.
Ken Sheridan
Stafford, England
I tried to follow Ken's instructions (reprinted below) very carefully but I
did not get them to work for me.
Here's what I did:
First, I created the DocumentsIssued table with the following
fields: Form_Number (which I tried to link to my Forms#_Title table), the
StartNumber, EndNumber and NumberIssued. Then I created a DocumentsIssued
Form and on the NunberIssued column AfterEvent, I entered the script Ken so
kindly provided. As my Form Numbers are alpha /numeric, I added the quotes
around the value. I also added the formatting to get 00001 for the Start and
End numbers.
My results? The form does not show the Form Numbers and it shows 00000 as
the StartNumber, 0 as the EndNumber and 000 as the NumberIssued (I programmed
this field to allow only three digits). Did I miss a step? When I issue ddo
forms for the first time, how will Access know that the StartNumber is 00001
and the EndNumber is 00025, if 25 forms were issued?
Also, from what I've told you, can you tell why the Form_Numbers from the
Forms#_Title table are not appearing in my DocumentIssued form? (The numbers
do appear in the Forms#_Title table .
Thanks, again Ken -- and all others who respond -- for your help.
Etta
Response from Ken...
Lets assume your table is called DocumentsIssued and it includes columns
DocumentID, StartNumber, EndNumber as well as the column for the
NumberIssued. In the data entry form, in the AfterUpdate event procedure of
the control bound to the NumberIssued column look up the last number issued,
and add 1 to get the next starting number and the value of the number issued
control to get the next ending number, assigning the two values to the
StartNumber and EndNumber controls, like so:
Dim intNumberIssued As Integer
Dim strCriteria as String
strCriteria = "[DocumentID] = " & Me.[DocumentID]
intNumberIssued = Nz(Dmax("[EndNumber]","[DocumentsIssued]", strCriteria),0)
Me.[StartNumber] = intNumberIssued + 1
Me.[EndNumber] = intNumberIssued + Me.[NumberIssued]
This assumes DocumentID is a number data type. If it were text you'd need
to wrap the value in quotes:
strCriteria = "[DocumentID] = """ & Me.[DocumentID] & """"
To show the numbers with leading zeros set the Format properties of the
StartNumber and EndNumber controls to 00000.
The above assumes that each document is issued to one department only rather
than to more than one department with the same number sequence used for each,
i.e. each starting with 1 rather than, for instance, one department using 1
to 25 and another department 26 to 50 and so on. If repetition of the same
numbers for the same document issued to different departments were the case
then the table would need to include a column such as DepartmentID and this
would need to be included in the criterion when calling the DMax function to
get the last number issued to that department, e.g.
strCriteria = "[DocumentID] = " & Me.[DocumentID] & " And [DepartmentID] = "
& Me.[DepartmentID]
Again this assumes both are of number data type.
Ken Sheridan
Stafford, England