Results 1 to 5 of 5
  1. #1
    BristolGarry is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    2

    Attempting to auto-update a subform field upon update of ID field

    Hi Folks -



    I have a database of clients who come into the adult learning lab where I work. We have a Daily Visits form where we enter who comes in and what they accomplish. Linked to this form is a subform that shows the last time the client filled out an intake form (which has to be done yearly).

    What I am trying to arrange is that when I open the Daily Visits form, the client ID gets transferred to the subform, and the subform then shows the intake date for that client. I also need the form to, when I choose another client to enter information for, update with the intake date of that newly chosen client.

    I have tried this code, but it only works for the first two clients, and then does not return any further intake dates.

    Private Sub Student_ID_Field_Change()
    Me.txt.FirstName.Value = Me.Student_ID_Field.Column(1)
    Me.txt.LastName.Value = Me.Student_ID_Field.Column(2)
    Me.ClientIntakeDates_subform.Form![ID] = Me.Student_ID_Field.Column(0)
    Me.ClientInnakeDates_subform.Form.Requery
    End Sub0

    The pertinent lines are the two "Me.ClientIntakeDates" lines. The Column(0) is the Client ID field of the client record.

    I am sure I am missing something relatively easy and straightforward here, and would appreciate any suggestions.

    Thanks in advance.

    Garry

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Garry,

    Welcome.
    Tell us about your tables --their name, primary keys,etc. and how they relate.

    I do see some variation in spelling.
    Me.ClientIntakeDates_subform.Form![ID] = Me.Student_ID_Field.Column(0)
    Me.ClientInnakeDates_subform.Form.Requery

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Or maybe you could/would make a copy of the dB, change any sensitive data, do a "Compact and Repair", then zip it and post it.
    Only need a couple of records.


    Shouldn't need any code.... Did you set the linking fields between the main form and the subform control?

    And the after update event would be better than the change event; the change event fires after every key stroke.
    Last edited by ssanfu; 03-28-2018 at 04:30 PM.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Should only save the student ID, not the name parts. If combobox is bound to field, the bound column value should save to table without code.

    Appears to be a misspelling: Me.ClientInnakeDates

    Why a 0 after End Sub? Just a typo in post?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Are you sure you want to use the Change event? This code will fire upon every keyboard press if the cursor is in the control, will it not?
    I'm surprised this would work Me.txt.LastName.Value, assuming it does.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 12-20-2016, 08:55 AM
  2. Auto update of date field
    By ase33592 in forum Forms
    Replies: 1
    Last Post: 08-05-2013, 02:32 PM
  3. Update field in table after update on a subform
    By jpkeller55 in forum Queries
    Replies: 3
    Last Post: 09-30-2010, 08:02 PM
  4. Replies: 3
    Last Post: 04-14-2010, 10:07 AM
  5. Replies: 1
    Last Post: 03-08-2009, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums