Combo box Search Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wayneyh
    New Member
    • Mar 2008
    • 67

    Combo box Search Problem

    Hello all

    I am trying to create a search form. I have a table called tblContact which has the field for postcodes in it. I have another table called tblSales which i have created a query to link the tblContacts to. On the frmSales the Postcode is a combo box. I am using the code below to search for the postcodes. I can't get it to find a postcode via the combo box. Sorry if i am not being very clear as my coding is very basic. Please help, thanks.


    Private Sub btnSearch_Click ()
    Dim strSearch As String

    If IsNull(Me![PostcodeSearch]) Or (Me![PostcodeSearch]) = "" Then
    MsgBox "You Must Enter A Postcode!", vbOKOnly, "Invalid Search!"
    Me![PostcodeSearch].SetFocus
    Exit Sub
    End If

    DoCmd.ShowAllRe cords
    DoCmd.GoToContr ol ("Postcode")
    DoCmd.FindRecor d Me!PostcodeSear ch

    Postcode.SetFoc us
    strPostcodeRef = Postcode.Text
    PostcodeSearch. SetFocus
    strSearch = PostcodeSearch. Text

    If strPostcodeRef = strSearch Then
    MsgBox "Match Found For: " & strSearch, , "Match Found!"
    Postcode.SetFoc us
    PostcodeSearch = ""

    Else
    MsgBox "No Match For: " & strSearch & " - Please Try Again.", _
    , "No Match Found!"
    PostcodeSearch. SetFocus
    End If
    End Sub
  • Wayneyh
    New Member
    • Mar 2008
    • 67

    #2
    Hi again

    The problem isn't the combo box as when i link the tblContact direct to the control source it works fine. so its linking through a query where i am having the trouble. Please advise. Regards

    Comment

    Working...