??????Still need help!!

Results 1 to 3 of 3

Thread: ??????Still need help!!

  1. #1
    Jaggy Guest

    Default ??????Still need help!!

    I&#039ve got a search form, that collects values from the user and searches a sqlserver dbase.<BR>The table has &#039firstname&#039 field and &#039surname&#039 field, for users to find a person. It&#039s fine if first or surname is entered, <BR>BUT-<BR>If a user puts first and second name in, or surname and then first name, no results are returned.<BR>How could I join the two fields so that such a search can be handled? Can&#039t use split function &#039cos don&#039t know which way round user will enter the names!???<BR><BR>Here&#039s the present code:<BR>If Len(varNAME) Then <BR> If len(sqlst) Then sqlst = sqlst & " AND "<BR> <BR> sqlst=sqlst & " (FirstName LIKE &#039%" & varNAME & "%&#039 OR Surname LIKE &#039%" & varNAME & "%&#039) "<BR> End If<BR><BR>?????Any help anyone????????

  2. #2
    Jim Andrews Guest

    Default RE: ??????Still need help!!

    You might try using a split and then checking Names(0) to see if there is a comma in it. If so, you can surmise that Names(0) is the surname, and Names(1) is the first name.<BR><BR>If there is no comma, then you can surmise that Names(0) is the first name and Names(UBound(Names)) would be the surname (You would use the UBound in case the user gets cheeky and puts in a middle name or middle initial)

  3. #3
    Jaggy Guest

    Default RE: ??????Still need help!!

    I&#039m still stuck, the code below doesn&#039t work, could you tell me why???<BR><BR>Also, will this work if a user enters first name, or surname, or first then surname without the comma????<BR><BR>If len(varNAME) Then<BR> If Len(sqltext) Then sqltext = sqltext & " AND "<BR> arrFullName = Split(varNAME,",")<BR> <BR> If arrFullName(0)&#062;0 Then sqltext = sqltext & "LAST_NAME = " & arrFullName(0)<BR> If arrFullName(0)&#062;0 And arrFullName(1)&#062;0 Then sqltext = sqltext & " AND "<BR> If arrFullName(1)&#062;0 Then sqltext = sqltext & "FIRST_NAME = " & arrFullName(1) <BR><BR> End If

Posting Permissions

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