Results 1 to 4 of 4
  1. #1
    joacro is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    4

    Changing row source

    Hi there,

    I have a form called Referal with two option buttons
    Then I have a combo box.
    Should I select the first option box the combo box row source should change to Consultants Name found in the Consultants extended query
    Should I select the second option box the combo row source should change to Brokers Name found in the Brokers extended query

    Here is what I put into the after update event
    rivate Sub cboRef_AfterUpdate()
    'load appropriate control source for Combo Box Referral Broker/Consultant
    Select Case Me![Objref]
    Case 1
    RowSource = "SELECT[Brokers Extended]"


    Me.cboRef.RowSource = "SELECT[Brokers Extended].[Broker Name],[Brokers Extended].*FROM[Brokers Extended]"

    Case 2

    Me.cboRef.RowSource = "SELECT[Consultants Extended].[Consultant Name],[Consultants Extended].*FROM [Consultants Extended]"

    End Select
    End Sub

    But I keep on getting a error saying "The record source on the specifiec form does not exist.

    Hope someone will be able to help me.

    Thanks in advance

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The code should be in the after update event of the frame (option group), not the combo box. Think about it. You are trying to modify the row source of the combo box, but you can only do it AFTER you have made a change to the combo box.

    And in both row source strings, you are missing spaces after "SELECT" and between the "*" and "FROM".

    Although it is not an "ERROR", you shouldn't use spaces in object names.
    (See http://mvps.org/access/tencommandments.htm - #3)


    Code:
    '-------------------------
    Private Sub Objref_AfterUpdate()
    'load appropriate control source for Combo Box Referral Broker/Consultant
      Select Case Me.[Objref]
        Case 1
          Me.cboRef.RowSource = "SELECT [Brokers Extended].[Broker Name],[Brokers Extended].* FROM[Brokers Extended]"
        Case 2
          Me.cboRef.RowSource = "SELECT [Consultants Extended].[Consultant Name],[Consultants Extended].* FROM [Consultants Extended]"
    
      End Select
    
      Me.cboRef.Requery
    End Sub
    Question: Why two tables? Are the fields for Brokers that much different than Consultants? I don't think your structure is normalized...

  3. #3
    joacro is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    4
    Thank you that sorted my problem

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I take it you are ready to use the Thread Tools and mark this thread as Solved?

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

Similar Threads

  1. changing form source while it's active! ??
    By debhead in forum Forms
    Replies: 1
    Last Post: 12-16-2010, 02:55 PM
  2. Replies: 4
    Last Post: 12-16-2010, 12:45 PM
  3. SQL vs. vba Row Source property
    By eww in forum Programming
    Replies: 7
    Last Post: 10-15-2010, 11:02 AM
  4. ComboBox Row Source Value
    By mpbertha in forum Forms
    Replies: 1
    Last Post: 08-21-2009, 06:34 AM
  5. Changing the record source in a form
    By lmichaud in forum Forms
    Replies: 1
    Last Post: 07-09-2006, 09:20 AM

Tags for this Thread

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