Results 1 to 5 of 5
  1. #1
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125

    Updating Default Value of a Subform Control

    I have a form where the user specifies the reason for a transmittal being sent through a combo box with options, then on that form there is a datasheet subform with line items where you can set the reason sent for each item (the combo box options are the same).



    I'm trying to make it where when the user selects the reason sent on the main form it will update the default value of the control on the subform to that same value. This is the code I'm using in the AfterUpdate of the combo box on the main form:

    Code:
    Me!sfrmTransDesc.Form!cboReasonSent.DefaultValue = Me.cboReasonSent.value
    and when it updates it gives me "#Name?" in the subform box.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You can try replacing
    Me.cboReasonSent.value
    with Forms!mainFormName.cboReasonSent.value

    where mainFormName is the name of your Main form

    I have a feeling if you are on the subform, ME is referring to that subform-- and the name isn't known.
    If you supply the full main form reference , it should work (not tested)

  3. #3
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Just tried your suggestion (seemed like a likely possibility) but got the same thing. So for safety's sake I supplied everything accross the board

    Code:
    Forms!frmrptTransLet!sfrmTransDesc.Form!cboReasonSent.DefaultValue = Forms!frmrptTransLet.cboReasonSent.value
    And it's still the same case. Not sure what's going on..

  4. #4
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    I was able to duplicate your problem, I believe. Your original references are ok, but I think you need to put quotes around it. So instead of Me!sfrmTransDesc.Form!cboReasonSent.DefaultValue = Me.cboReasonSent.value, try:

    Me!sfrmTransDesc.Form!cboReasonSent.DefaultValue = "'" & Me.cboReasonSent.value & "'"

  5. #5
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    You are correct! Problem solved, thanks!

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

Similar Threads

  1. add subform to TAB control?
    By haggisns in forum Forms
    Replies: 2
    Last Post: 10-13-2010, 07:21 AM
  2. Subform in Switchboard not updating
    By TrudyD1474 in forum Forms
    Replies: 2
    Last Post: 06-29-2010, 07:50 AM
  3. Updating subform based on combo box change
    By kev921hs in forum Forms
    Replies: 3
    Last Post: 04-01-2010, 08:43 AM
  4. updating a control
    By Seven in forum Forms
    Replies: 3
    Last Post: 12-20-2009, 09:31 PM
  5. Replies: 1
    Last Post: 11-14-2006, 02:32 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