Results 1 to 8 of 8
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    Requery Combo Box on open?

    HI all,
    I fixed my earlier issue yet i cannot get my combo box to display on open or changing from record to record? One works, the other doesnt. I have attached db so maybe someone can tell me what i am missing here to get it to display correctly. The data is there, just not showing up in combo.

    Form CompanyProfileFrm, CboAddressType


    The CboAddressType should show up on open and changing from record to record but it doesnt. For the life of me this is a headache!

    Thanks
    DavedbProfileNew.zip

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The rowsource for the combobox is

    SELECT [CompanyTypeTbl].[CompanyTypeID], [CompanyTypeTbl].[CompanyType] FROM CompanyTypeTbl ORDER BY [CompanyTypeID];

    The DB does not contain table or query CompanyTypeTbl.

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    I had to remove a lot of stuff to get it small enough to upload so some things are missing. However, the one i am refering to is the CboAddressType further down the form. Next to Manage Address button.

    RowSource = SELECT [AddressID], [CompanyLocationID], [AddressTypeID], [AddressType], [Reference], [Preferred] FROM CompanyAddressByLocationQry ORDER BY [Preferred];

    The data is there if you drop down, but not showing up automatically? Have no idea why not but somehting somewhere is not refreshing or reqerying at some point needed. The combo above it works just fine so why doesnt this one?
    Thanks
    Dave

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    When i open that form , CompanyProfileFrm, then the CboLocation and the CboAddressType combos should populate as long as there is data available. So, the CboLocation works just as expected...Populates on open, changes on record change and so on. The CboAddressType does not do this as expected, as long as the data is there, then it should show up automatically, not have to use the drop down unless you want to change the address type and address info.
    Thanks
    Dave

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    CboLocation is unbound so there is no data for CboAddressType to filter with when form opens. Requery CboAddressType after CboLocation has data - at end of Current event.

    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
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    dbProfileNew.zip

    OK, I gave it one more try, actually several but i did get it to work. Not sure if its the correct method but it does work, Attached new copy of it working.

    So what i did was on Form_Current i moved the Me.CboAddressType.Requery after the CboLocation = DLookup.... and then I Put this code in

    Code:
    Private Sub CboLocation_AfterUpdate()    Me.CboAddressType.Requery
            CboAddressType = DLookup("AddressID", "CompanyAddressByLocationQry", "CompanyLocationID=" & [CboLocation] & " AND Preferred=True")
            If IsNull(CboLocation) Then
            CboAddressType.Enabled = False
        Else
            CboAddressType.Enabled = True
        End If
        
    End Sub
    Which is the same thing i have in the Form_Current so i am thinking this is most likely not correct method. I am sure there is some rowsource = stuff or something that would work better so if you have anything, please let me know. I would love some advice here.
    Thanks

  7. #7
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Hi June7,
    It uses a DLookup for a Qry so the data is there, and i did get it to work finally.... So i posted what i did, not sure correct method but it worked
    Thank you
    Dave

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I know DLookup populates unbound combobox but code requeries combobox before DLookup. In Current event, all I did was move Requery lines to after DLookup lines and it worked.
    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.

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

Similar Threads

  1. Requery 1 of 3 forms that is open
    By vad77 in forum Forms
    Replies: 2
    Last Post: 04-20-2020, 04:08 PM
  2. Replies: 9
    Last Post: 06-03-2014, 09:33 AM
  3. Combo Box Will Not Requery
    By clchapin in forum Programming
    Replies: 3
    Last Post: 08-01-2013, 08:51 AM
  4. Replies: 2
    Last Post: 06-03-2013, 11:52 AM
  5. Replies: 1
    Last Post: 03-13-2011, 02:29 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