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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6,dataenvironment, excepting textbox input to sql statements

Status
Not open for further replies.

bandb

Technical User
Aug 19, 2003
3
0
0
US
I am trying to access fields from an access2k database using vb6, dataenvironment and showing a datareport.
I am trying to use the data from two text boxes in my sql statement to initiate the report.

SELECT DATE, [FIRST NAME], [LAST NAME], COST1, COST2
FROM EXPENSES
WHERE DATE BETWEEN '" &TEXTDATE1.TEXT &"' AND "' & TXTDATE2.TEXT &"'

The ubove where clause is all one line. This does not work.
What would be the correct code to maqke this work?


 
Try this,

...WHERE DATE BETWEEN '#" &TEXTDATE1.TEXT &"#' AND "'# & TXTDATE2.TEXT &"#'"


The number signs qualify the value within as a date. It has been a while since I worked with Access and I am not sure whether the single quotes should remain or be removed. You will find out if it works with the single quotes soon enough.

Thanks and Good Luck!

zemp
 
Zemp;
Thanks for your help. Unfortunately '#"&txtdate1.text&"#'
does not work. I even tried '"# & txtdate.text & #"' and
'"& #txtdate.text# &"' and '"#txtdate.text#"' and
'" &txtdate.text& "'
I am at the end of a project and this is my demise.
the SQL statement is in a command section of the dataenvironment. This allows the datareport to show the results of the search.

If anyone has an idea I am open for suggestions.

Thanks
bandb

 
Sounds like you need to pass parameters to the Data Environment. The process and some code are posted in thread 709-472900.

Good Luck.

awelch

 
Yes, but did you try:

...WHERE DATE BETWEEN #" & TEXTDATE1.TEXT & "# AND #" & TXTDATE2.TEXT & "#"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top