LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default 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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search form? nkoichev Excel Discussion (Misc queries) 0 July 5th 06 02:27 PM
search form in sheet peter via OfficeKB.com New Users to Excel 3 June 24th 05 11:10 PM
Search Form kylev96 Excel Programming 0 June 2nd 05 04:13 PM
Search form Bernd[_2_] Excel Programming 3 April 22nd 04 03:56 PM
use a txt.value on a form to search a sheet Zygoid[_15_] Excel Programming 2 February 1st 04 04:15 PM


All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"