Is there any way to create an Input Mask that would give something like
this
upon creating a new record?
06/05/22-SB-01
Where 06/05/22 (today's date) and -SB would be populated automatically and
all we would have to do is type in 01, 02, 03 at the end?
Each day we have many checks come in and we organize them into batches.
The field in question is the Primary key in the main form and the subform
has all of the reocurring checks that are related to this batch number.
SB,
SM, LO stand for different office names and 01, 02, 03... stand for
different
batches in the same day.
It would be nice if this field could be populated each day completely by
knowing what today's date is and then sequentially adding to the batch
number
for each new batch that day. Would you know of a way to do this?
Well... I'd say, DON'T.
This is called an "Intelligent Key" - and that's not a compliment!
Storing three disparate types of information in one field is A Very
Bad Idea, and a good recipe for trouble down the line.
I'd suggest instead using *three* fields - a date/time field, default
value Date(), to record the date the record was entered; a two-byte
text field for the office (you can use a Combo Box to fill this),
defaulting to the user's office; and an integer sequence field. You
can use code in your form's BeforeInsert event to fill in the sequence
number:
Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtSeqNo = NZ(DMax("[SeqNo]", "YourTableName", "[Office]='" &
Me!cboOffice & "' AND CheckDate = #" & Date() & "#")) + 1
End Sub
Use the AfterUpdate event of the Office combo if one user may be
entering data for multiple offices.
You can make these three fields a joint Primary Key; or, if you
prefer, create a unique Index on the three fields, and use an
Autonumber primary key.
John W. Vinson[MVP]