Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form - data entry (Access XP)

    In my PTA database I have a form with data entry fields for (along with other ones of course):
    Childs first name
    Childs Surname
    Parent of Guardian First name
    Parent or Guardian Surname

    Generally the Parent or Guardian's Surname is the same as the Childs Surname.
    What I would like to have happen is that when the Childs Surname is entered, it is also automatically entered in the Parent or Guardian Surname field. This is primarily to cut down on data entry (there are 1500+ kids!!) and to increase data entry accuracy.

    I have played around with default values in conjunction with properties such as on click etc, but can't seem to get a result.

    Any ideas?

    Thanks...Peter

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

    Re: Form - data entry (Access XP)

    You have to use VBA to do this. In case you're not familiar with Access VBA, I'll tyry to indicate what you should do. Otherwise, you can skip to the end of this post. I'm using a non-English version of Access, so my wording may be slightly off, but I hope you'll get the general idea.
    <UL><LI>In form design, select the Childs Surname text box.
    <LI>Open (if necessary) the Properties window and select the Events tab.
    <LI>Select After Update, click on the continuation button (...) and select Program code builder.
    <LI>A module window opens with the skeleton of a sub (procedure) ready for you to use.
    <LI>Hit the Tab key, and then type
    <pre>If IsNull([Parent or Guardian Surname]) Then
    [Parent or Guardian Surname] = [Childs Surname]
    End If</pre>
    [/list]The procedure should look like this:

    Private Sub Childs_Surname_AfterUpdate()
    If IsNull([Parent or Guardian Surname]) Then
    [Parent or Guardian Surname] = [Childs Surname]
    End If
    End Sub

    I have assumed that you want to copy the Childs Surname only if the Parent or Guardian Surname is still empty. If you want to copy it each time the Childs Surname is modified, remove the lines
    If IsNull(..) Then
    and
    End If

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form - data entry (Access XP)

    Brilliant!

    That works perfectly.

    Thanks very much

    Peter

Posting Permissions

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