dcsimg
Results 1 to 5 of 5
  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2018
    Posts
    54

    combobox that finds record based on order number typed

    i have a combo box that finds a record on my form based on order number i select in the drop down , is there a way i can get it to auto populate if i search part of the order number instead of the whole thing.

    EXAMPLE:
    instead of typing 000018052913 in the combo box i would like to type in 2913

    Name:  hhhh.PNG
Views: 104
Size:  5.1 KB

    basically i dont want to type the 0000 part every time

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,543

    Re: combobox that finds record based on order number typed

    try
    where ordernumber like '@2913'
    of course there could be multiple results
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2018
    Posts
    54

    Re: combobox that finds record based on order number typed

    do you think that would be under property sheet > validation rule
    'Like '@'

    because i dont want to limit it to just that order number

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,543

    Re: combobox that finds record based on order number typed

    i dont want to limit it to just that order number
    of course not, that was just an example

    Code:
    "where ordernumber like '@" & txtordernum & "'"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Member pike's Avatar
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    44

    Re: combobox that finds record based on order number typed

    try,,,
    Code:
    Private IsArrow As Boolean
    Private Sub ComboBox1_Change()
    Dim i As Long
        With Me.ComboBox1
            If Not IsArrow Then .List = Range("YourList").Value
            If .ListIndex = -1 And Len(.Text) Then
                For i = .ListCount - 1 To 0 Step -1
                   If Not .List(i) Like "*" & .Text & "*" Then .RemoveItem i
                 '  If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
                Next i
                .DropDown
            End If
        End With
    End Sub
    
    Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown
        If KeyCode = vbKeyReturn Then Me.ComboBox1.List = Range("YourList").Value
    End Sub
    Last edited by pike; Jun 16th, 2018 at 02:07 AM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.