Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    automatic field entry (2002)

    I've done this before but I can't remember the coding.
    I am entering data in a form. First field is StudID.
    I finish one row of data and want to go to the next record and have the same StudID as the previous record automatically placed in the new record.
    How do I code it to do this.

    Thanks

    Paul

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: automatic field entry (2002)

    The best way I've found is to move the value of StudID into the DefaultValue. You can do this in either the AfterUpdate event of the StudID control or in the form's AfterUpdate event. You need to be careful if StudID is text rather than numeric, as you need to include the quotes. Assuming your controlname is txtStudID, you'd use either of these:

    txtStudID.DefaultValue = txtStudID 'if numeric
    or
    txtStudID.DefaultValue = chr(34) & txtStudID & chr(34) ' if text
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: automatic field entry (2002)

    Manually: type Ctrl+' (apostrophe) in the field in the new record.

    Automatically: see How to fill record with data from previous record automatically in Access 2000 (also applies to Access 2002 and later)

  4. #4
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: automatic field entry (2002)

    Just an added comment about Mark's default value suggestion. One handy, yet sometimes overlooked, advantage of setting a default value, instead of setting the actual value, is that a default value will display to the user, BUT WILL NOT enter data in the table, until other fields are used. As an example, if Joe User opens your form, enters one record, then moves to a new record, if Joe decides he doesn't want to enter that record, he'll just close the form. If you have used code to set the value (not default value) of the field, then you either end up with a partially empty record, with just the 'automated' fields filled in, OR if you have data validation in place/required fields, Joe User will get prompts when trying to close the form, because a record was created, but not completed.

    On the other hand, if you have your code set the default value, and Joe User closes your form after going to a new record, no 'partially empty' records are created, nor does Joe User get any data validation prompts.

    I post this once in a while, when I see this type of topic arise, because I've been the Joe User too many times, who was plagued with message boxes when I just wanted to close a form! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: automatic field entry (2002)

    One more way to do this kind of thing - and we use it frequently - is to use a subform, so that the StudID is automatically picked up from the main form. It will often work in such situations.
    Wendell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •