Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Toledo, Ohio, USA
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subsetting a combo box's contents

    Post deleted by jp2558

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subsetting a combo box's contents

    If I understand you correctly you want the user to enter something into a textbox and use the contents of the textbox to filter the rowsource of your combobox right? That isn't hard to do. Here's an old example of how I've done it in the past with the user typing in the first letter or letters of the last name OR the first few characters of a contactID and using that to set the rowsource of a combobox. If you have the combobox rowsource set to a saved query, you can get an idea of how to modify your query's SQL to use the value in the textbox.

    <img src=/w3timages/green2line.gif width=33% height=2>
    <pre>Private Sub txtMatch_AfterUpdate()
    'This is the afterupdate event of the textbox
    Call SetFindSrc
    End Sub</pre>


    <pre>Public Sub SetFindSrc()
    ' modified 12/1/98
    Dim strSQL As String

    If Not IsNull([txtMatch]) Then

    strSQL = "SELECT DISTINCTROW tblCntct.cntctID, " _
    & "tblCntct.LastName,tblCntct.FirstName," _
    & "tblCntct.MiddleName,tblOrgnzn.OrgnznName " _
    & "FROM tblOrgnzn RIGHT JOIN tblCntct " _
    & "ON tblOrgnzn.OrgnznID = tblCntct.OrgnznID " _
    & "WHERE (((tblCntct.cntctID) Like '" _
    & [txtMatch] & "*') Or ((tblCntct.LastName) " _
    & "Like '" & [txtMatch] & "*'" & ")) "


    strSQL = strSQL & " ORDER BY tblCntct.cntctID, " _
    & "tblCntct.LastName, tblCntct.FirstName, " _
    & "tblCntct.MiddleName;"

    [cboFindContact].RowSource = strSQL
    [cboFindContact].Requery
    [cboFindContact].SetFocus
    End If

    End Sub</pre>

    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Toledo, Ohio, USA
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subsetting a combo box's contents

    Charlotte, thanks so much as this worked exactly as I'd hoped. All I need to do now is to be able to remove the value entered in the text box so that the entire combo box contents are then displayed/reset.

    FYI, if you ever have any questions regarding the IBM AS/400 feel free to ask as that is my platform of choice for my professional career and I've been an RPG programmer for 15 years.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Subsetting a combo box's contents

    Just add a line at the end of the routine to set the TextBox =null. This is where creating the combobox rowsource on the fly works better than using a saved query because the "on the fly" SQL includes the literal value you're using rather than a reference to the textbox, so the value of the textbox can change without affecting the combobox.

    I haven't needed to work with AS/400 for anything in years and I've never had to deal with RPG, but I'll keep the offer in mind. [img]/w3timages/icons/grin.gif[/img]
    Charlotte

Posting Permissions

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