Default value in a field

  • Thread starter Thread starter Todd
  • Start date Start date
T

Todd

I'm asking a question in reference to one I asked the
other day. I want to make my form where when I check the
trng check box, one of the other fields (msn#) will
automatically default a prefix number (FUN022). This
prefix will never change for training.

I got a response saying to use the AfterUpdate event of
the trng checkbox, then add script to set the other
field. I'm not good with code so would someone tell me
what to do.

Basically, I'm trying to keep from having to enter this
prefix everytime I enter training info. Also, how can I
make the cursor when I tab to the msn# field it will set
itself at the end of the default number?
 
Hi Todd,

I'll explain a couple of ways of doing this but first I would suggest that
you consider taking the prefix number out of the msn# field and put it into
it's own field. Typically when you see fields that have predefined prefixes
(or suffixes) they are throwbacks to legacy or paper systems that didn't
have the flexibility of a relational database. You can still combine fields
on forms and reports to *display* the coded value but it is far better to
store the individual pieces of data in separate fields. This is part of the
normalization process.

To get the result you want you could add the following to the Enter event of
the msn# control:

Me.[msn#].Text = "FUN022"
Me.[msn#].SelStart = 7

Note that by hardcoding this into your application, you will have to make
design changes whenever someone decides that "FUN022" should be "FUN024"
(they say it will never happen but trust me, never comes sooner than you
think!!).

If you'd like more information on normalizing the data post back with more
details.
 
Back
Top