Search form
propertyHi!
I am trying to build a search form that extracting records from a list and
present them in a list box. I am using the following code:
' Get SelectStatement.
Dim Position As Integer
Dim SelectStatement As String
Position = InStr(1, Me.Result.RowSource, "WHERE")
SelectStatement = Me.Result.RowSource
'Build WhereCondition.
Dim WhereCondition As String
WhereCondition = "True = True"
If Not IsNull(Me.txtTitle) Then
WhereCondition = WhereCondition & " and Me.Title Like '*" &
Me.txtTitle & "*'"
End If
If Not IsNull(Me.txtAuthorName) Then
WhereCondition = WhereCondition & " and Me.AuthorName Like '*" &
Me.txtAuthorName & "*'"
End If
If Not IsNull(Me.txtJournalName) Then
WhereCondition = WhereCondition & " and Me.JournalName Like '*" &
Me.txtJournalName & "*'"
End If
If Not IsNull(Me.txtYear) Then
WhereCondition = WhereCondition & " and Me.Year Like '*" & Me.txtYear
& "*'"
End If
If Not IsNull(Me.txtKeywords) Then
WhereCondition = WhereCondition & " and Me.Keywords Like '*" &
Me.txtKeywords & "*'"
End If
'Build SQL String.
Dim SQL As String
SQL = SelectStatement & " WHERE " & WhereCondition & ";"
'Pass SQL to ListBox.
Me.Result.RowSource = SQL
and I am stucked in the last line which trigger runtime error '380' that the
RowSource couldn't be set due to invalid property value.
Can anyone suggest why?
Thanks in advance
Eli
|