Results 1 to 3 of 3

Thread: [RESOLVED] Combo Box to Populate subForm

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Miami, Florida
    Posts
    161

    Question [RESOLVED] Combo Box to Populate subForm

    Needed some help with an afterupdate combo box event. The combo box holds information about building numbers, once a building is selected I would like to populate a subform with all available units. I have two tables, tblBldgs and tblUnits with a propertyid as the key on both. The main form is unbound and the combo box is populated by a select statement.

    How can I populate a subform after making a combo box selection?

    Thanks
    Last edited by root2; Sep 13th, 2004 at 02:53 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Miami, Florida
    Posts
    161

    Followup Code

    This is the code I currently have behing the afterupdate combo box "cboPropertyid" on frmPropertyPage3.

    AfterUpdate Event
    VB Code:
    1. Private Sub cboPropertyid_AfterUpdate()
    2.     'Call subroutine to set filter based on selected PropertyID
    3.     Call SetFilter
    4. End Sub

    Call to SetFilter
    VB Code:
    1. Sub SetFilter()
    2.  
    3.     Dim LSQL  As String
    4.     LSQL = "SELECT * FROM subUnit WHERE subUnit.propertyid = """ & Me.Parent.cboPropertyid & """"
    5.     Form_fsubUnitList.RecordSource = LSQL
    6.    
    7. End Sub

    This is what I have on the properties of the form fsubUnitListing
    data: SELECT * FROM subUnit WHERE subUnit.propertyid=181;

    When I run the application I get the following:

    run-time error 2001
    You cancelled a previous operation

    ---> Form_fsubUnitList.RecordSource = LSQL

    The information being displayed is the data which I setup in the properties of the fsubUnitListing.

    I am completely lost HELP!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Miami, Florida
    Posts
    161

    Talking [RESOLVED]

    Wow...figured this silly thing out.

    The problem existed with the SELECT statement I had incorrectly added too many quotes causing my SELECT statement to fail. Thanks to everyone for taking a look at my code, this site has always taken me out of jams before but glad to have resolved it myself.

    VB Code:
    1. Dim LSQL  As String
    2.     LSQL = "SELECT * FROM subUnit WHERE subUnit.propertyid = " & Me.cboPropertyid
    3.     Form_fsubUnitList.RecordSource = LSQL

    Hopefully this posting serves as a good reference to someone in need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width