...

View Full Version : query database by phone number



havey
03-15-2006, 02:52 AM
connection to a sql db, my select statement is not working for Telephone and fax numbers otherwise it does work, any suggestions?

//garrItem is from a text field in a form on the same page

If Trim(garrItem) <> "" Then

If gstrSql = "" Then
gstrSql = "SELECT TOP 50 MemberID, FirstName, LastName, EmailAddress, GradYear, ProvinceName, OptJoinProgram, Unsubscribe, LaOn, LoyaltyPoint, MDelect, Phar_Select, Fax, Tel" _

& " FROM Member LEFT JOIN Province ON Member.ProvinceID = Province.ProvinceID" _

& " WHERE"

If gstrFilter = "membersonly" Then
gstrSql = gstrSql & " MD_Select = 0 AND Pharmacists_Select = 0 AND"
End If

Else
gstrSql = gstrSql & " AND "
End If

gstrSql = gstrSql & " (FirstName LIKE '" & Replace(Trim(garrItem), "'", "''") & "%'"
gstrSql = gstrSql & " OR LastName LIKE '" & Replace(Trim(garrItem), "'", "''") & "%'"
gstrSql = gstrSql & " OR EmailAddress LIKE '" & Replace(Trim(garrItem), "'", "''") & "%'"
gstrSql = gstrSql & " OR Tel LIKE '" & garrItem & "%'"
gstrSql = gstrSql & " OR Fax LIKE '" & garrItem & "%'"

If IsNumeric(garrItem) Then
gstrSql = gstrSql & " OR GradYear = " & garrItem & " OR MemberID = " & garrItem & ")"
Else
gstrSql = gstrSql & ")"
End If

End If

havey
03-15-2006, 03:39 AM
forgot to mention that the ph#s & fax# are in this format: xxx-xxx-xxxx

degsy
03-15-2006, 02:34 PM
Response.Write gstrSql to see what is being sent



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum