unique id numbers

F

Freddy

i need to create unique delivery id numbers together with part of branch name
EG
branch name
Peckham
Croydon
i use DMax("DelvNo",Booking")+1 which gives me the next increament number
but i would like to add part of the branch name so that i get the next number
for a particular barnch.
i.e
Branch Del No
PECK 3 or
CROY 8

Thanks In advance
 
G

Guest

hi,
a little skimpy on the details but heres an idea
all you really have to do is...
DMax("DelvNo",Booking")+1 & branch
but you may have to pre-qualify. in other words you would
have to know which brach the next number was for.
before accually calculating the next number, you could use
dlookup to create a variable with the brank name
DMax("DelvNo",Booking")+1 & variable
untested. shooting from the hip here.
 
J

John Vinson

i need to create unique delivery id numbers together with part of branch name
EG
branch name
Peckham
Croydon
i use DMax("DelvNo",Booking")+1 which gives me the next increament number
but i would like to add part of the branch name so that i get the next number
for a particular barnch.
i.e
Branch Del No
PECK 3 or
CROY 8

Thanks In advance

DMax has an optional third parameter, specifying the critera which
limit the domain over which the maximum is to be sought. Try putting
the branch into the criteria: obviously, you cannot do this in the
Form's BeforeInsert event if the branch has not yet been selected, so
you may want to use the AfterUpdate event of the Branch combo box:

Private Sub cboBranch_AfterUpdate()
Me!DelvNo = NZ(DMax("[DelvNo]", "[Booking]", "[Branch] = '" _
& Me!cboBranch & "'")) + 1
End Sub


John W. Vinson[MVP]
 
Top