J
John
Hi
I need to assign sequential numbers to a field to some records in a table. I
am opening a recordset and assigning the numbers as follows;
Sub MyButton_Click()
While Not rs.EOF
If rs![Account Type] = "Account" Then
rs.Edit
If IsNull(rs![Invoice No]) Then
rs![Invoice No] = Forms![MyMainForm]![lastinvno].Form![lastinvno]
+ 1
Me.lastinvno.Requery
Me.Requery
Me.Refresh
End If
rs.MoveNext
Wend
End Sub
MyMainForm is the form with the button that is running this code. lastinvno
is a field on a subform lastinvno. The lastinvno field is assigned the
expression; Max(IIf(IsNull([Invoice No]),0,[Invoice No])).
The problem I have is that some records are being assigned duplicate numbers
and as you can imagine, duplicate invoice numbers are not good. How can I
ensure that records are assigned unique values?
Thanks
Regards
I need to assign sequential numbers to a field to some records in a table. I
am opening a recordset and assigning the numbers as follows;
Sub MyButton_Click()
While Not rs.EOF
If rs![Account Type] = "Account" Then
rs.Edit
If IsNull(rs![Invoice No]) Then
rs![Invoice No] = Forms![MyMainForm]![lastinvno].Form![lastinvno]
+ 1
Me.lastinvno.Requery
Me.Requery
Me.Refresh
End If
rs.MoveNext
Wend
End Sub
MyMainForm is the form with the button that is running this code. lastinvno
is a field on a subform lastinvno. The lastinvno field is assigned the
expression; Max(IIf(IsNull([Invoice No]),0,[Invoice No])).
The problem I have is that some records are being assigned duplicate numbers
and as you can imagine, duplicate invoice numbers are not good. How can I
ensure that records are assigned unique values?
Thanks
Regards