URGENT! select date1 until date2 and more field Help Please...
i am new to mysql but have good experience with vb
i have created a mysql with table dss
but i`m confused about this
this is the table of dss
-----------------
date | drivers | Group | SPeed |
-----------------
01/01/2006 2111 north 64
02/01/2006 2121 north 53
03/01/2006 2145 north 43
04/01/2006 2187 south 77
05/01/2006 2133 north 35
06/01/2006 2165 south 38
07/01/2006 2181 north 38
08/01/2006 2135 north 42
09/01/2006 2111 north 43
10/01/2006 2124 south 41
11/01/2006 2113 north 45
12/01/2006 2109 north 75
13/01/2006 2106 north 75
14/01/2006 2111 north 75
15/01/2006 2123 south 90
------------------
then i want select the date from 01/01/2006 until 10/01/2006 with
the driver is 2111 with group north and with speed from 24 until 90
i made date with dtpicker and drivers,group and speed with textbox
please help me what kind of code what must i have
i has been made some sql statement
mstrSQL = "SELECT * from dss WHERE (Date>= #" &
DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)"
AND driver='" & txtdriver.text & "'" AND group='" & txtgroup.text & "'"
AND (speed >='" & txtspeed1.text & "'") AND (speed <='" & txtspeed1.text & "'")
but still not show
please help me? URGENT!
thanks
[1492 byte] By [
joanleonz] at [2007-11-11 8:51:28]

# 1 Re: URGENT! select date1 until date2 and more field Help Please...
if you are new to sql, I suggest you to simplify your query, putting only one parameter (e.g. select * where group =)
When you are sure that that is working, add another test and see how it goes.
BTW which parameter type did you use to define the "date" field?
Marco
mstraf at 2007-11-11 17:24:53 >

# 2 Re: URGENT! select date1 until date2 and more field Help Please...
i use date as date/time on ms access
but i just want to select the date from 01/01/2006 until 10/01/2006 with
the driver is 2111 with group north and with speed from 24 until 90
mstrSQL = "SELECT * from dss WHERE (Date>= #" &
DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)"
AND driver='" & txtdriver.text & "'" AND group='" & txtgroup.text & "'"
AND (speed >='" & txtspeed1.text & "'") AND (speed <='" & txtspeed1.text & "'")
but still not show :(
anybody can tell me whats wrong about the sql statement?
help me
# 3 Re: URGENT! select date1 until date2 and more field Help Please...
joanleonz,your using Date as a field name is a lot suspicious!Date is supposed to be a reserved word,how can you use it as a field name?Try changing it.
# 4 Re: URGENT! select date1 until date2 and more field Help Please...
joanleonz,your using Date as a field name is a lot suspicious!Date is supposed to be a reserved word,how can you use it as a field name?Try changing it.
Hi soft,
if you look carefully, you'll see that Date is inside a sql query String, and therefore cannot be confused with a keyord...
In this context, it is the name of a recordset field
Marco
mstraf at 2007-11-11 17:27:59 >

# 5 Re: URGENT! select date1 until date2 and more field Help Please...
joanleonz,I suspect the Speed field is numeric.In that case,why did you enclose the speed values in quotes in the criteria expression?This is wrong & will result in "data type mismatch in criteria expression" error.
# 6 Re: URGENT! select date1 until date2 and more field Help Please...
i have good experience with vb
but i have some serious problems
i have created a mysql with table dss
but i`m confused about this
i think many people will see this problem in future
this is the table of dss
--------------------
Date | Drivers | Group | Speed | Score |
--------------------
01/01/2006 2111 north 64 98
02/01/2006 2121 north 53 95
03/01/2006 2145 north 43 96
04/01/2006 2187 south 77 94
05/01/2006 2133 north 35 92
06/01/2006 2165 south 38 100
07/01/2006 2181 north 38 80
08/01/2006 2135 north 42 60
09/01/2006 2111 north 43 44
10/01/2006 2124 south 41 85
11/01/2006 2113 north 45 82
12/01/2006 2109 north 75 96
13/01/2006 2106 north 75 99
14/01/2006 2111 north 75 87
15/01/2006 2123 south 90 56
------------------
then i want select the date from 01/01/2006 until 10/01/2006 with
the driver is 2111 with group north and with speed from 24 until 90 with score from 50 until 100 and show it into datagrid
but i can selected any in checkbox and unselected to show what field i just wanna filtered
i made date with dtpicker and drivers,group speed and score with textbox
then i made selected field that i want to filtered with checkbox
this is the details
==================================
check1.value for date
check2.value for drivers
check3.value for group
check4.value for speed
check5.value for score
==================================
date1 = dtpicker1.value
date2 = dtpicker2.value
drivers = txtdrivers.text
group = cbogroups.text (combo box)
speed = txtspeed1.text and txtspeed2.text
score = txtscore1.text and txtscore2.text
==================================
this is a link the picture of the forms
http://www.geocities.com/joanleonz/forms.gif
please help me what kind of code what must i have
please help me? URGENT!
thanks
# 7 Re: URGENT! select date1 until date2 and more field Help Please...
Don't know if it is just a typo in your post, or if you actually have it in you query, but there are a couple of errors :-
mstrSQL = "SELECT * from dss WHERE (Date>= #" &
DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)"
AND driver='" & txtdriver.text & "'" AND group='" & txtgroup.text & "'"
{the ... "'" AND ... etc. in the line above should be ... "' AND ... }
AND (speed >='" & txtspeed1.text & "'") AND (speed <='" & txtspeed1.text & "'")
{as with the previous line, the "'") AND ... should be ... "') AND ... }
gupex at 2007-11-11 17:30:57 >

# 8 Re: URGENT! select date1 until date2 and more field Help Please...
:(
details of the tables of dss
======================
date (data type = date)
drivers = (Data type = text)
groups ( data type = text)
speed ( data type = text)
score ( data type = text)
=====================
i want select the date from 01/01/2006 until 10/01/2006 with
the driver is 2111 with group north and with speed from 24 until 90 with score from 50 until 100 and show it into datagrid
but i can selected any in checkbox and unselected to show what field i just wanna filtered
i made date with dtpicker and drivers,group speed and score with textbox
then i made selected field that i want to filtered with checkbox
this is the details
==================================
check1.value for date
check2.value for drivers
check3.value for group
check4.value for speed
check5.value for score
==================================
date1 = dtpicker1.value
date2 = dtpicker2.value
drivers = txtdrivers.text
group = cbogroups.text (combo box)
speed = txtspeed1.text and txtspeed2.text
score = txtscore1.text and txtscore2.text
==================================
this is a link the picture of the forms
http://www.geocities.com/joanleonz/forms.GIF
please help me what kind of code what must i have
i write some code
mstrSQL = "SELECT * from dss WHERE (Date>= #" &
DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)"
AND driver='" & txtdriver.text & "'" AND group='" & txtgroup.text & "'"
AND (speed >='" & txtspeed1.text & "'") AND (speed <='" & txtspeed2.text & "'") AND (score >='" & txtscore1.text & "'") AND (score <='" & txtscore2.text & "'")
but still not showing
i`m so confused
any good answer?
help me please........
# 9 Re: URGENT! select date1 until date2 and more field Help Please...
See my previous post - your SELECT query still has the same errors that I referred to. Reviewing your SELECT, you also have errors at the beginning of your 3rd and 4th lines, but this might just be the way in which you copied and pasted for the forum - they also need a " to begin them (as well as & at the end of the previous lines).
gupex at 2007-11-11 17:33:07 >

# 10 Re: URGENT! select date1 until date2 and more field Help Please...
Try this one...
"SELECT * from dss WHERE (Date>= #" &
DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)
AND driver='" & txtdriver.text & "' AND group='" & txtgroup.text & "'
AND (speed >='" & txtspeed1.text & "') AND (speed <='" & txtspeed2.text & "') AND (score >='" & txtscore1.text & "') AND (score <='" & txtscore2.text & "')"
gupex was right.. it might be only a typo, you got extra "(double qoutes) in your query :D and a missing "(double qoute) in the end of the query :( . tell me if this helped you. :WAVE:
# 11 Re: URGENT! select date1 until date2 and more field Help Please...
lordnikotine
syntax error (missing operator)
http://www.geocities.com/joanleonz/forms.GIF
i want to be like that froms
i can selected / unselected what field that i want to filtered by clicking checkbox and then click submit(filter) to run that processed and show it into datagrid
please help me what code that must i have...
# 12 Re: URGENT! select date1 until date2 and more field Help Please...
Work with something like this ...
bAtLeastOne = False
mstrSQL = "SELECT * from dss WHERE "
(if bAtLeastOne is False at the end of all the checks, then don't run query - unless you want
'ALL' (in which case remove 'WHERE') - although you could cater for this in the first time
you set bAtLeastOne to true by adding ' WHERE ')
If chkDate.Value = vbChecked then
mstrSQL = mstrSQL & "(Date>= #" & DTdate1.value & "#) AND (Date<= #" & DTdate2.value & "#)"
bAtLeastOne = True ' This is to only have 'AND' if you already have one parameter
EndIf
If chkDrivers.Value = vbChecked Then
if bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
EndIf
mstrSQL = mstrSQL & " driver='" & txtdriver.text & "'
bAtLeastOne = True
EndIf
etc ...
gupex at 2007-11-11 17:36:06 >

# 13 Re: URGENT! select date1 until date2 and more field Help Please...
thanks...
i think same with you
but still not show
i dont know why
:(
this is the forms
http://www.geocities.com/joanleonz/forms.GIF
by the way this is the data type of table dss
==========================
date ===> data type = date
drivers ===> data type = text
groups ===> data type = text
speed ===> data type = number
score ===> data type = number
==========================
this is the code for filter the checkbox
======================================
Private Sub cmdfilter_Click()
Set rsdss = New Recordset
rsdss.ActiveConnection = con
rsdss.CursorType = adOpenStatic
rsdss.CursorLocation = adUseClient
rsdss.LockType = adLockOptimistic
bAtLeastOne = False
mstrSQL = "SELECT * from dss WHERE "
If Check1.Value = vbChecked Then
mstrSQL = mstrSQL & "(Date>= #" & dtpicker1.value & "#) AND (Date<= #" & dtpicker2.value & "#)"
bAtLeastOne = True
End If
If Check2.Value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & " driver='" & txtdriver.Text & "'"
bAtLeastOne = True
End If
if check3.value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & " groups='" & txtdriver.Text & "'"
bAtLeastOne = True
end if
if check4.value = vbchecked then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & mstrSQL = mstrSQL & "(speed>= #" & txtspeed1.Text & "#) AND (Date<= #" & txtspeed2.Text & "#)"
bAtLeastOne = True
end if
if check5.value = vbchecked then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & mstrSQL = mstrSQL & "(score>= #" & txtscore1.Text & "#) AND (score<= #" & txtscore2.Text & "#)"
bAtLeastOne = True
end if
rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic
end sub
========================================
maybe conflict with data type or parameter "#" and i has been made with "'" too but still not show and i dont know why
i`m so confused :confused:
please help me.........
# 14 Re: URGENT! select date1 until date2 and more field Help Please...
The following code appears twice in your last post :-
"mstrSQL = mstrSQL & mstrSQL = mstrSQL & "(whatever)"
remove the second "mstrSQL = mstrSQL & " leaving :-
"mstrSQL = mstrSQL & "(whatever)"
Put a breakpoint on the line :-
"rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic"
and see what mstrSQL contains (try and run the query in Access or whatever database you are using).
gupex at 2007-11-11 17:38:04 >

# 15 Re: URGENT! select date1 until date2 and more field Help Please...
not show the database after i click command button filter
this is the code
==================================
Private Sub cmdfilter_Click()
Set rsdss = New Recordset
rsdss.ActiveConnection = con
rsdss.CursorType = adOpenStatic
rsdss.CursorLocation = adUseClient
rsdss.LockType = adLockOptimistic
bAtLeastOne = False
mstrSQL = "SELECT * from dss WHERE "
If Check1.Value = vbChecked Then
mstrSQL = mstrSQL & "(Date>= #" & txtdate1.Text & "#) AND (Date<= #" & txtdate2.Text & "#)"
bAtLeastOne = True
End If
If Check2.Value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & " driver='" & txtdriver.Text & "'"
bAtLeastOne = True
End If
If Check3.Value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & " groups='" & txtdriver.Text & "'"
bAtLeastOne = True
End If
If Check4.Value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & "(speed>= #" & txtspeed1.Text & "#) AND (Date<= #" & txtspeed2.Text & "#)"
bAtLeastOne = True
End If
If Check5.Value = vbChecked Then
If bAtLeastOne Then
mstrSQL = mstrSQL & " AND "
End If
mstrSQL = mstrSQL & "(score>= #" & txtscore1.Text & "#) AND (score<= #" & txtscore2.Text & "#)"
bAtLeastOne = True
End If
rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic
End Sub
==============================================
i has been upload the project,forms and database.mdb with winzip
please help repair
thanks a lot
# 16 Re: URGENT! select date1 until date2 and more field Help Please...
As per previous post ...
Put a breakpoint on the line :-
"rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic"
and see what mstrSQL contains (try and run the query in Access or whatever database you are using).
Please advise contents of mstrSQL at this point.
Greg
gupex at 2007-11-11 17:40:13 >
