Re: Generating Unique Numbers on a Form with Multi-users
- From: "Keith Wilby" <here@xxxxxxxxx>
- Date: Tue, 19 Dec 2006 09:00:41 -0000
Hi Rick.
"Rick Brandt" <rickbrandt2@xxxxxxxxxxx> wrote in message
news:OFvhh.23942$wc5.17767@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Keith Wilby" <here@xxxxxxxxx> wrote in message
news:45864dc6$1_1@xxxxxxxxxxxxxxxxxxxxxxxxx
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in message
news:O$dZngFIHHA.4896@xxxxxxxxxxxxxxxxxxxxxxx
Not sure that's appropriate in a multi-user environment, Keith. While
the odds are very low, it's possible two users may grab the same value
that way.
Works fine for me Doug, but I always do a refresh immediately and don't
allow deletions (provide a "deleted record" flag instead).
What does refreshing have to do with it? If a user navigates to the new
record position he can let the form sit like that indefinitely before he
actually enters and saves a record.
I think you may have misunderstood. I have Allow Additions set to False and
the following code in the button's click event.
Private Sub cmdNext_Click()
Me.txtUniqueNo.DefaultValue = Nz(DMax("MyField", "qryMyQuery")) + 1
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.AllowAdditions = False
End Sub
I haven't worked on this app in a while but IIRC "Me.AllowAdditions = False"
has the effect of saving the record, rather like a Me.Refresh.
During that interval numerous other users will have already used the
default number on his form as well as many higher ones. He is virtually
guaranteed to get an error unless your idea of "multi-user" is very
conservative.
Not to mention that assigning this value with the DefaultValue property
doesn't work at all on a continuous form (even in a single user app).
I think that two or more users clicking the button at *exactly* the same
instant is a remote possibility, so remote that the risk is negligible. It
hasn't happened for this particular app in the 10 years it's been in use.
Regards,
Keith.
.
- References:
- Generating Unique Numbers on a Form with Multi-users
- From: Nerida via AccessMonster.com
- Re: Generating Unique Numbers on a Form with Multi-users
- From: Keith Wilby
- Re: Generating Unique Numbers on a Form with Multi-users
- From: Douglas J. Steele
- Re: Generating Unique Numbers on a Form with Multi-users
- From: Keith Wilby
- Re: Generating Unique Numbers on a Form with Multi-users
- From: Rick Brandt
- Generating Unique Numbers on a Form with Multi-users
- Prev by Date: Re: Autopopulate Problem, i.e., Null Value
- Next by Date: Re: Position of Cursor in field
- Previous by thread: Re: Generating Unique Numbers on a Form with Multi-users
- Next by thread: Generating Unique Numbers on a Form with Multi-users
- Index(es):