Results 1 to 4 of 4
  1. #1
    NickvdM is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    3

    Combo box changes text property when other properties are changed in VBA

    Greetings, fellow Access programmers

    I have a situation where i want to run and incremental search (can you even do that?) on the bound column of a combo box. I am using an option group to determine which query should be used to specify the row source in the combo box. Said differently, change the order in which the columns are displayed so that it also makes sense to the user by presenting it in a logical order. Everything is fine and dandy until I change the properties of the combo box in VBA. See my code below. I can't for the life of me understand how the Text property is there are no instructions for it. Is there how I circumvent this and keep the text the user types in in the combo box?

    Please help! I've been on this for a week now and trying to find solutions to no avail.

    Here is my code:

    Code:
        If Me.optSearchMethod = 1 Then        
            strSQL = "SELECT * FROM qrySearchByHospID WHERE qrySeachByHospID!txtPtHospID LIKE '" & Me.cboPatient.Text _
                & "' AND qrySearchByHospID.txtLocationMnemonic = 'ICU';"
            varCboBoxValue = Me.cboPatient.Value
            Me.cboPatient.RowSource = strSQL
            cboPatient.ColumnCount = 6
            ' Me.cboPatient.Text changes to "" after excecuting this instruction.
            cboPatient.ColumnWidths = "4cm., 4cm., 4cm., 1cm., 1.5cm., 3cm.)"
        Else
            strSQL = "SELECT * FROM qrySearchBySurname WHERE qrySearchByHospID!txtPtSurname = LIKE '" & Me.cboPatient.Text _
                & "' AND qrySeachByHospID!txtLocationMnemonic = 'ICU';"
            Me.cboPatient.RowSource = strSQL
            Me.cboPatient.ColumnCount = 6
            ' cboPatient.Text changes to "" after executing this instruction.
            Me.cboPatient.ColumnWidths = "4cm., 4cm.,4cm., 1.5cm., 1cm., 3cm."
        End If
    Thanks in advance, and happy coding.
    Last edited by NickvdM; 05-07-2022 at 09:22 PM. Reason: Put code in quote code tags as advised

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Perhaps this will help http://allenbrowne.com/ser-32.html

    Note for future: Please post code between CODE tags to retain indentation and readability.
    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.

  3. #3
    NickvdM is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    3
    Thank you June7.

    So we learn something new every day.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Advice was to use CODE tags, not QUOTE. CODE tags can be generated by clicking # icon on editor menu. Paste code between tags.
    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. Property Sheet - Query Properties
    By vinfurnier in forum Queries
    Replies: 1
    Last Post: 06-19-2018, 08:43 AM
  2. Replies: 2
    Last Post: 03-08-2017, 10:19 AM
  3. Replies: 2
    Last Post: 04-24-2016, 08:10 AM
  4. Replies: 2
    Last Post: 03-27-2013, 11:03 AM
  5. Replies: 5
    Last Post: 06-23-2012, 04:30 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