Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working Access 2000 MDB "search" code not working in a 2003 ADP 1

Status
Not open for further replies.

embryo

Programmer
Nov 27, 2004
46
US
The following search code works great in an Access 2000 database, but now that I've convered to an Access 2003 ADP, it doesn't return any results:
-----------------------------------------------------


Private Sub btn_OK_Click()
On Error GoTo btn_OK_Err

Dim strWhere As String
Dim strAnd As String
Dim strSelect As String

strSelect = "Select [DebtorID],[AccountName],[DebtorFirstName], [DebtorLastName], [SpouseName], [ClientID], [HomePhone], [OtherPhone], [Address1], [City], [State], [POE], [DebtorID], [DL_number] from [tblDebtors]"
strAnd = ""
strWhere = ""



If Not IsNull(Me!TxtAcctName) And Me!TxtAcctName <> "" Then
strWhere = strWhere & strAnd & " AccountName like '" & Me!TxtAcctName & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtLast) And Me!TxtLast <> "" Then
strWhere = strWhere & strAnd & " DebtorLastName like '" & Me!TxtLast & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtSpouse) And Me!TxtSpouse <> "" Then
strWhere = strWhere & strAnd & " SpouseName like '" & Me!TxtSpouse & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtClientID) And Me!TxtClientID <> "" Then
strWhere = strWhere & strAnd & " ClientID like '" & Me!TxtClientID & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtPhone) And Me!TxtPhone <> "" Then
strWhere = strWhere & strAnd & " HomePhone like '" & Me!TxtPhone & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtOtherPhone) And Me!TxtOtherPhone <> "" Then
strWhere = strWhere & strAnd & " OtherPhone like '" & Me!TxtOtherPhone & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtAddress1) And Me!TxtAddress1 <> "" Then
strWhere = strWhere & strAnd & " Address1 like '" & Me!TxtAddress1 & "*'"
strAnd = " And"
End If


If Not IsNull(Me!TxtCity) And Me!TxtCity <> "" Then
strWhere = strWhere & strAnd & " City like '" & Me!TxtCity & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtState) And Me!TxtState <> "" Then
strWhere = strWhere & strAnd & " State like '" & Me!TxtState & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtPOE) And Me!TxtPOE <> "" Then
strWhere = strWhere & strAnd & " POE like '" & Me!TxtPOE & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtDebtorID) And Me!TxtDebtorID <> "" Then
strWhere = strWhere & strAnd & " DebtorID like '" & Me!TxtDebtorID & "*'"
strAnd = " And"
End If

If Not IsNull(Me!TxtDLNumber) And Me!TxtDLNumber <> "" Then
strWhere = strWhere & strAnd & " DL_NUmber like '" & Me!TxtDLNumber & "*'"
strAnd = " And"
End If


If Not IsNull(strWhere) And strWhere <> "" Then
Forms!FrmDebtorList!Combo0.RowSource = strSelect & "Where" & strWhere
Else
Forms!FrmDebtorList!Combo0.RowSource strSelect
End If

btn_Ok_Done:
DoCmd.Close

Exit Sub

Forms!FrmDebtorList!Combo0.Requery

btn_OK_Err:
MsgBox Error$

GoTo btn_Ok_Done

End Sub

-----------------------------------------------------

Any ideas why?

Thanks,
Steve

Steve
---------------------------------------
IF WebApplicationProgrammer = True Then
ElectronicSheepHerder = True
End If
 
Check out the differences between ANSI standard SQL, which SQL Server uses, and Access SQL, which is proprietary.

The standard wildcard is %
The standard literal definition is single quote '

These are a couple of differences - a couple of the more common ones.
 
The wildcard was the issue-
Thanks much-

Steve

Steve
---------------------------------------
IF WebApplicationProgrammer = True Then
ElectronicSheepHerder = True
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top