Setting up database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've put fields in a new table that ZI've created to start a database
tracking biopsy slides for a doctors office...the first field must be a
unique number in order to track the slides and i want every number to begin
with the last 2 digits of current year..for exemple the first slide would be
07-1 then 07-2....07-1003 and on and on...I would like this number to be
geberated automatically when a person begins to log in info to database...Is
this possible, and How
 
yes, you can use the form BeforeInsert event ---

'~~~~~~~~~~
dim mNum as long
mNum = nz(dMax("mid(SlideNo,3,len(SlideNo)-3)" _
, "Tablename" _
, "Left(SlideNo,2)='" = format(Date(),"yy") & "'") _
,0) + 1
me.SlideNo = format(Date(),"yy") _
& "-" & mNum
'~~~~~~~~~~

where
SlideNo is a text field containing the slide number

personally, I would take this one step further so that slide numbers are
always in the same format (0000 if it will not go past 0000, 00000 if it
will) so that they will sort properly
....
me.SlideNo = format(Date(),"yy") _
& "-" & format(mNum,"0000")


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
correction:

0000 if it will not go past 9,999

0 is a placeholder specifying that a digit must be reported -- leading
0's (zeros) will be used for numbers less than that many digits

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
Back
Top