Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    35

    Unanswered: Read a serach text

    I need to realize a serch by the firstname and the lastname of one person but when I run this code not appear any person. It is code correct?

    Private Sub cmdSearchByName_Click()
    Dim strSQL As String

    'Set row source for list box
    strSQL = "SELECT DISTINCTROW CurrentDate, PassNumber, CustomerValue, FirstName, LastName, DepartmentName, CompanyName, TypeOfPassValue, TypeOfMaterial, Quantity, ReturnDate, CurrentUser, Status, CurrentDate FROM tblPass WHERE FirstName =" & Me.txtFirstName & " AND LastName = " & Me.txtLastName & " Order By FirstName Asc"

    Me!lstSearch.RowSource = strSQL
    Me!lstSearch.Requery
    End Sub

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    string parameters in the where clause need to be quoted:

    ...

    WHERE Firstname = '" & me.txtFirstname & "' AND LastName = '" & Me.txtLastName & "' ORDER BY FirstName Asc"

    If you want to be REALLY nitpicky, you should be using LIKE instead of =
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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