Results 1 to 7 of 7
  1. #1
    twcaddelll is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    3

    Listbox rowsource not available

    Hi All,


    I have a form with two listboxes. (ContractsListBox and AppsListBox).
    ContractsListBox lists all the contracts available. The idea when a contract is selected, the afterupdate event fires, extracting the selection as a string, compose a SQL query and "tries" to change the rowsource of the AppsListbox.
    Code is
    Code:
    Private Sub ContractListBox_AfterUpdate()
    Dim j As Long
    Dim Contract As String
        Contract = Me.ContractListBox.Value
        strSQL = "SELECT [ContractFileNames].[FileNameID], [ContractFileNames].[APP] FROM ContractFileNames WHERE Contract='" & Contract & "';"
        Debug.Print strSQL
        Me.AppBoundList.RowSource = strSQL
    End Sub
    I initially populate the AppsListBox with a SQL query that lists all the apps across all the contracts and apps show when I first run the form.
    However, when I try to select a contract, I get "Compiler error: Method or data member not found" and the rowsource method is highlighted in the IDE.
    I would appreciate any ideas because I'm hitting my head against the wall thus far.
    Thanks
    tc

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Show a picture of those fields in that table.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Move the code to the on_click event.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Looks like your missing a "s" in the list box name (and the names are different????):

    Me.AppBoundList.RowSource = strSQL

    I have a form with two listboxes. (ContractsListBox and AppsListBox).
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't need table name prefix. Don't need Contract variable. Check spelling of listbox name.

    strSQL = "SELECT [FileNameID], [APP] FROM ContractsFileNames WHERE Contract='" & Me.ContractsListBox & "';"

    Would be better to filter on ID field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    twcaddelll is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    3
    Thank you. I didn't realize I could do a filter here. Will read up on it.

  7. #7
    twcaddelll is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2023
    Posts
    3
    will take a look at it. Thanks

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

Similar Threads

  1. Search within access listbox rowsource
    By bubai in forum Access
    Replies: 13
    Last Post: 01-24-2022, 06:14 AM
  2. Replies: 2
    Last Post: 11-01-2018, 07:31 AM
  3. Reversing rowsource order for a multicolumn listbox
    By wackywoo105 in forum Programming
    Replies: 6
    Last Post: 12-10-2014, 06:26 AM
  4. Updating listbox rowsource not working
    By j2curtis64 in forum Forms
    Replies: 13
    Last Post: 12-07-2011, 01:46 PM
  5. ListBox RowSource Update Not working in 2003
    By Access0307 in forum Programming
    Replies: 1
    Last Post: 05-05-2011, 07:41 PM

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