Results 1 to 4 of 4
  1. #1
    km8415 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    1

    Control Source for Text Box (#error)

    I have a text box on a form with the control source tied to the value of a field from a datasheet embedded as a subform on my main form.



    textbox.controlsource = EA_Subform.Form![Exhibit_#]

    Everything works fine until the subform which holds the Exhibit_# doesn't have any records returned.

    When this happens, the value in the textbox is now #Error.

    Is there an IIF statment I could put in the control source of the textbox which would set the text box value to "" if there are no records returned in the subform?

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    If either the subform's primary key is Null or the subform's recordset contains no records (your choice) then no subform record exists, else a subform record exists.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Paul's method is correct.

    Or you could use thee build function from the wizard.

    This answer should be ignored as I was thnking of something else.

    Appologies.

    If fact it would be better if a Moderator could delete this post.
    Last edited by Rainlover; 06-27-2010 at 11:02 AM. Reason: Big Mistake. Sorry

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

Similar Threads

  1. Setting a Color on a Control For Error
    By AccessLes in forum Programming
    Replies: 6
    Last Post: 06-16-2010, 12:35 PM
  2. one form two sources - invalid control source msg
    By techexpressinc in forum Forms
    Replies: 1
    Last Post: 05-28-2010, 02:11 PM
  3. Replies: 1
    Last Post: 04-29-2010, 05:15 PM
  4. Replies: 2
    Last Post: 07-30-2009, 08:02 AM
  5. Control source and calculated values
    By meistersteff in forum Forms
    Replies: 0
    Last Post: 11-23-2007, 07:04 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