Problems loading a listbox rowsource from code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Corey

    Problems loading a listbox rowsource from code

    I am having some real trouble getting a listbox rowsource to load
    properly. The listbox is actually on a subform. My main form has
    several command buttons that change the MASTER_SUB_FORM object source
    to the specific sub form needed by the end user. When designing the
    sub form i used the querybuilder to create an SQL statment to define
    the listbox values.

    ****
    RowSource SQL Statement
    ****

    SELECT [CAN_LAST] & ", " & [CAN_FIRST] AS Name,
    CANDIDATES.INTE RVIEW_TIME AS [Scheduled At] FROM CANDIDATES WHERE
    (((CANDIDATES.E VENT)=FORMS!SEL ECT_INTERVIEW!S ELECT_INTERVIEW _EVENT))
    GROUP BY [CAN_LAST] & ", " & [CAN_FIRST], CANDIDATES.INTE RVIEW_TIME
    ORDER BY CANDIDATES.INTE RVIEW_TIME;


    As you can see, I use an object(combobox ) as criteria
    (Forms!SELECT_I NTERVIEW!SELECT _INTERVIEW_EVEN T)

    When i only have the subform open this works fine. However, when i try
    and load the subform from the main form I get a query prompt that says
    Forms!SELECT_IN TERVIEW!SELECT_ INTERVIEW_EVENT .

    What would cause this? Is there a way around this? I would really,
    greatly appreciate any advise from you pro's

  • Larry  Linson

    #2
    Re: Problems loading a listbox rowsource from code

    The Form displayed in a Subform control is neither "Open" nor is it in the
    Forms! collection. You must refer to it as the .Form property of the Subform
    control.

    Larry Linson
    Microsoft Access MVP



    "Corey" <coreyfleming@y ahoo.com> wrote in message
    news:1108004333 .077967.25310@o 13g2000cwo.goog legroups.com...[color=blue]
    > I am having some real trouble getting a listbox rowsource to load
    > properly. The listbox is actually on a subform. My main form has
    > several command buttons that change the MASTER_SUB_FORM object source
    > to the specific sub form needed by the end user. When designing the
    > sub form i used the querybuilder to create an SQL statment to define
    > the listbox values.
    >
    > ****
    > RowSource SQL Statement
    > ****
    >
    > SELECT [CAN_LAST] & ", " & [CAN_FIRST] AS Name,
    > CANDIDATES.INTE RVIEW_TIME AS [Scheduled At] FROM CANDIDATES WHERE
    > (((CANDIDATES.E VENT)=FORMS!SEL ECT_INTERVIEW!S ELECT_INTERVIEW _EVENT))
    > GROUP BY [CAN_LAST] & ", " & [CAN_FIRST], CANDIDATES.INTE RVIEW_TIME
    > ORDER BY CANDIDATES.INTE RVIEW_TIME;
    >
    >
    > As you can see, I use an object(combobox ) as criteria
    > (Forms!SELECT_I NTERVIEW!SELECT _INTERVIEW_EVEN T)
    >
    > When i only have the subform open this works fine. However, when i try
    > and load the subform from the main form I get a query prompt that says
    > Forms!SELECT_IN TERVIEW!SELECT_ INTERVIEW_EVENT .
    >
    > What would cause this? Is there a way around this? I would really,
    > greatly appreciate any advise from you pro's
    >[/color]


    Comment

    • Corey

      #3
      Re: Problems loading a listbox rowsource from code

      Larry,

      Im sorry but im totally drawing a blank. Can you help me a little
      here? By refering to it as the .form property what exactly would i be
      doing. Thanks for your help!

      Comment

      • pietlinden@hotmail.com

        #4
        Re: Problems loading a listbox rowsource from code

        REad this article... it explains it all.



        Comment

        • Corey

          #5
          Re: Problems loading a listbox rowsource from code

          So i changed up my criteria a little and the form at least loads now
          without the query prompt. But now the listbox doesnt load.
          Appearntly, I am still missing something, any ideas? Should I be
          creating the rowsource from code or can i still use the query builder
          to build the SQL statement from the list box properties box?

          Comment

          Working...