View Full Version : how to specify parameters in sql statement?


zambam
04-23-2007, 08:16 AM
hi,

i have written an sql statement to display fields from a table. but i want it to do this based on a date range (the user enters a parameter)

this can happen in access, but im using vb6 to do this and i dont know how to specify the parameter to wait for user input to filter the results

pls help

boblarson
04-23-2007, 08:40 AM
hi,

i have written an sql statement to display fields from a table. but i want it to do this based on a date range (the user enters a parameter)

this can happen in access, but im using vb6 to do this and i dont know how to specify the parameter to wait for user input to filter the results

pls help

The best way is to have the user select the date/dates on a form and reference the form's controls.

zambam
04-23-2007, 10:53 AM
thanks, but how would i do that? im using vb6

thanks

boblarson
04-23-2007, 11:22 AM
Sorry, I missed that one. I'll have to defer to someone else as I haven't done a lot with what you're needing in VB6.

KjWhal
04-23-2007, 01:19 PM
I don't remember, does access have the date/time picker control?

The trick will be getting the users to enter data in date/time format.

I say have 2 textboxes (maybe put a date/time mask on them) and a button, user puts in the start/end of the range and presses the button. You build the string like

"select blah blah from blah blah where start = ' " & startTextbox & " ' and finish = ' " & endTextbox & " ' "

set the query equal to the string and then run the query.

I'll have an actual code example when I get into work tommorow.

zambam
04-23-2007, 02:14 PM
I don't remember, does access have the date/time picker control?

The trick will be getting the users to enter data in date/time format.

I say have 2 textboxes (maybe put a date/time mask on them) and a button, user puts in the start/end of the range and presses the button. You build the string like

"select blah blah from blah blah where start = ' " & startTextbox & " ' and finish = ' " & endTextbox & " ' "

set the query equal to the string and then run the query.

I'll have an actual code example when I get into work tommorow.

thanks pls do, id really appreciate that.

in the meantime ill try figure it out from what you have said.

zambam
04-23-2007, 02:21 PM
this is an example of one of the things i have:

SELECT `Member ID`, Forename, Surname, `Date Loaned`
FROM Loans

i want the user to specify a date range so all the loans between that date range are shown. in access, to enter a parameter as all of you already know it would be between[start date] and [end date]. but in vb6 sql builder, i cant use this as a parameter.