Results 1 to 4 of 4
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Populating a subforms Text Boxes


    I thought I had this licked and behind me a week ago, but under slightly different conditions I found a bug that's kept me busy for 1/2 a day. Either I'll solve this while writing this description (a frequent occurrence) or I'll put it in your capable hands. I'm ready to move on. I have two fields in a the subform's table that need to be populated by the two fields that make up the primary key in the master table, P_RegNo and Admit_Date. The subform is a continuous form and as each record is keyed a row for a new record is created. I was using the On Current event to populate these fields.

    Code:
    Private Sub Form_Current()
        Me.txtP_RegNo = Form_Clinical_Summary.P_RegNo
        Me.txtAdmit_Date = Form_Clinical_Summary.Admit_Date
    End Sub
    This is causing this error message "Index or Primary Key cannot contain a Null." on several events. When I first wrote this I did not seem to have this problem.

    What I want is for each new record to populate those new fields, .... ah ha!

    OK, here is my right now solution. I've moved this code to my forms Before Update event which appears to have fixed the problem. I always get ideas as I'm laying out these problems and about half the time I come up with "a" solution, if not "the" solution. I'm not going to mark this solved just yet, so if you have any comments or insights, please add them.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If this is a form/subform arrangement and this is compound key (I avoid them), why not use Master/Child Links?
    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.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Yeah, why didn't I just do that? Too easy I think. I had no idea that would auto populate. I must have missed that day in class.

    Thanks for breaking it to me gently.

    Paul

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    re: Compound keys. I do too. As with most of my work lately, this is somebody else's baby.

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

Similar Threads

  1. Populating forms with subforms
    By Katiemay in forum Forms
    Replies: 1
    Last Post: 07-12-2013, 11:12 AM
  2. Replies: 1
    Last Post: 10-28-2011, 01:57 PM
  3. Replies: 17
    Last Post: 08-19-2011, 01:19 PM
  4. Replies: 15
    Last Post: 09-18-2010, 01:19 PM
  5. Help with Subforms/Combo Boxes
    By mikel in forum Forms
    Replies: 11
    Last Post: 06-03-2009, 07:45 AM

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