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!

Is a Listbox rowsource the same syntax as ado recordset source

Status
Not open for further replies.

kalvis

Technical User
Mar 15, 2001
9
I have a form with text boxes that a person can enter information in that is then used to search a table. When a "Load" command button is pushed a SQL statement is built using the info in the textboxes. This SQL statement is then used as the rowsource of a listbox.

I have another button that on the form that is used to output the information in the listbox to a word document. I use the SQL statement that populates the list box to open an ADO recordset, move through the recordset to build a string and then insert the string into MS Word.

Everything works great populating the list box with the dynamic SQL statement. If I dont have any information in the text boxes on the form the ADO recordset opens fine and I can output it to the MS Word document. But if I add info to the text boxes the ADO recordset does not open up correctly(recordcount=0)

The only difference between opening the ADO recorset with information in the text boxes and no information in the text boxes is whether or not the SQL statement contains a WHERE clause.

Is it possible that the SQL statement needs different syntax when a WHERE clause is used in an ADO recordsource. Also, I have pasted the SQL statements that are generated into Access queries and the records always pull up as they should.

Hope this all makes sense. Thanks in advance for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top