msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help me about Filter
Goto page 1, 2  Next
 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
dokter.cinta



Joined: 04 Oct 2007
Posts: 2

PostPosted: Sat Jun 17, 2006 4:59 pm    Post subject: Help me about Filter Reply with quote

hi all....

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 have this problem in future
this is the table of dss
==================
date (data type = date)
drivers(data type = text)
group (data type = text)
speed(data type = number)
score (data type =number)
==================

-----------------------------------------------------------------
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
i has been wite some code...(still error )
but i want with checkbox like the forms on
http://www.geocities.com/joanleonz/forms.GIF
so i can pick up what field that i want to be filtered
this is the code
---------------------------------------------------------------------------­------

Private Sub Form_Load()
con.ConnectionString = _
"PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=" & App.Path & "\database.mdb;"
con.Open
Set rssppd = New Recordset
rssppd.ActiveConnection = con
rssppd.CursorType = adOpenStatic
rssppd.CursorLocation = adUseClient
rssppd.LockType = adLockOptimistic
rssppd.Open "select * from dss"
Set DataGrid1.DataSource = rssppd
End Sub
---------------------------------------------------------------------------­---

Private Sub cmdfilter_Click()
Set rssppd = New Recordset
rssppd.ActiveConnection = con
rssppd.CursorType = adOpenStatic
rssppd.CursorLocation = adUseClient
rssppd.LockType = adLockOptimistic
strsql = "select * from dss where date between date >='" &
(dtpicker1.Text) & "'" & _
"and date <='" & (dtpicker2.Text) & "'" & " and drivers='" &
txtdrivers.Text & "'" & _
"and groups='" & cbogroups.Text & "'" & _
"and speed>='" & txtspeed1.Text & "'" & _
"and speed>='" & txtspeed2.Text & "'" & _
"and score>='" & txtscore1.Text & "'" & _
"and score>='" & txtscore2.Text & "'"
rssppd.Open strsql, con, adOpenStatic, adLockBatchOptimistic
end sub


please help me what kind of code what must i have
please help me? URGENT!


thanks

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Sat Jun 17, 2006 9:31 pm    Post subject: Re: Help me about Filter Reply with quote

wrote
> i have good experience with vb
> but i have some serious problems

Instead of posting many times, you should probably have
asked someone to proofread your question to be sure it
is properly understood. As you might know, if a question
cannot be understood, then an answer will not be possible.

To put it mildly, your english needs improvement.....

> i have created a mysql with table dss
> but i`m confused about this

What is confusing?


> but i can selected any in checkbox and unselected to show what field i
> just wanna filtered


> strsql = "select * from dss where date between date >='" & (dtpicker1.Text) & "'" & _
> "and date <='" & (dtpicker2.Text) & "'" & " and drivers='" & txtdrivers.Text & "'" & _
> "and groups='" & cbogroups.Text & "'" & _
> "and speed>='" & txtspeed1.Text & "'" & _
> "and speed>='" & txtspeed2.Text & "'" & _
> "and score>='" & txtscore1.Text & "'" & _
> "and score>='" & txtscore2.Text & "'"

> please help me what kind of code what must i have
> please help me? URGENT!

The WHERE clause needs to be built dependant on the state of
your checkboxes. There is nothing in the statements above that
tests which textboxes are checked.

It should be more like:

strAddAnd = ""

strSQL = "SELECT * FROM dss WHERE"

If Check1.Value = vbChecked Then
strSQL = strSQL & " date >='" & (dtpicker1.Text) & "'" & "AND date <='" & (dtpicker2.Text) & "'"
strAddAnd = " AND"
End If

If Check2.Value = vbChecked Then
strSQL = strSQL & strAddAnd & " groups='" & cbogroups.Text & "'"
strAddAnd = " AND"
End If

If Check3.Value = vbChecked Then
strSQL = strSQL & strAddAnd & " speed >='" & txtspeed1.Text & "' AND speed<='" & txtspeed2.Text & "'"
strAddAnd = " AND"
End If

.... etc... (for all checkboxes)


HTH
LFS
Back to top
View user's profile Send private message
dokter cinta



Joined: 04 Oct 2007
Posts: 42

PostPosted: Wed Jun 21, 2006 7:54 am    Post subject: Re: Help me about Filter Reply with quote

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
==================================================


but still not working
any body can help me?
please give me a good answer about the code


thanks




Larry Serflaten wrote:
> wrote
> > i have good experience with vb
> > but i have some serious problems
>
> Instead of posting many times, you should probably have
> asked someone to proofread your question to be sure it
> is properly understood. As you might know, if a question
> cannot be understood, then an answer will not be possible.
>
> To put it mildly, your english needs improvement.....
>
> > i have created a mysql with table dss
> > but i`m confused about this
>
> What is confusing?
>
>
> > but i can selected any in checkbox and unselected to show what field i
> > just wanna filtered
>
>
> > strsql = "select * from dss where date between date >='" & (dtpicker1.Text) & "'" & _
> > "and date <='" & (dtpicker2.Text) & "'" & " and drivers='" & txtdrivers.Text & "'" & _
> > "and groups='" & cbogroups.Text & "'" & _
> > "and speed>='" & txtspeed1.Text & "'" & _
> > "and speed>='" & txtspeed2.Text & "'" & _
> > "and score>='" & txtscore1.Text & "'" & _
> > "and score>='" & txtscore2.Text & "'"
>
> > please help me what kind of code what must i have
> > please help me? URGENT!
>
> The WHERE clause needs to be built dependant on the state of
> your checkboxes. There is nothing in the statements above that
> tests which textboxes are checked.
>
> It should be more like:
>
> strAddAnd = ""
>
> strSQL = "SELECT * FROM dss WHERE"
>
> If Check1.Value = vbChecked Then
> strSQL = strSQL & " date >='" & (dtpicker1.Text) & "'" & "AND date <='" & (dtpicker2.Text) & "'"
> strAddAnd = " AND"
> End If
>
> If Check2.Value = vbChecked Then
> strSQL = strSQL & strAddAnd & " groups='" & cbogroups.Text & "'"
> strAddAnd = " AND"
> End If
>
> If Check3.Value = vbChecked Then
> strSQL = strSQL & strAddAnd & " speed >='" & txtspeed1.Text & "' AND speed<='" & txtspeed2.Text & "'"
> strAddAnd = " AND"
> End If
>
> ... etc... (for all checkboxes)
>
>
> HTH
> LFS
Back to top
View user's profile Send private message
Jan Hyde



Joined: 04 Oct 2007
Posts: 1211

PostPosted: Wed Jun 21, 2006 4:43 pm    Post subject: Re: Help me about Filter Reply with quote

"dokter cinta" 's wild thoughts were
released on 21 Jun 2006 03:54:01 -0700 bearing the following
fruit:

>this is the forms


Please read up on what muliposting is and why you should not
do it.

J


Jan Hyde (VB MVP)

--
Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.

(Donna Eaker)
Back to top
View user's profile Send private message
dokter cinta



Joined: 04 Oct 2007
Posts: 42

PostPosted: Wed Jun 21, 2006 8:56 am    Post subject: Re: Help me about Filter Reply with quote

i`m so sorry
because i`m so confused and no ppl answer my question
i has been write more and more code about my problems about the filter
using checkbox
and its doesnt work
i hope you can tell me what code that must i have

dokter cinta ( the fans of Microsoft Visual Basic)

Jan Hyde wrote:
> "dokter cinta" 's wild thoughts were
> released on 21 Jun 2006 03:54:01 -0700 bearing the following
> fruit:
>
> >this is the forms
>
>
> Please read up on what muliposting is and why you should not
> do it.
>
> J
>
>
> Jan Hyde (VB MVP)
>
> --
> Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.
>
> (Donna Eaker)
Back to top
View user's profile Send private message
Jan Hyde



Joined: 04 Oct 2007
Posts: 1211

PostPosted: Wed Jun 21, 2006 7:04 pm    Post subject: Re: Help me about Filter Reply with quote

"dokter cinta" 's wild thoughts were
released on 21 Jun 2006 04:56:21 -0700 bearing the following
fruit:

>i`m so sorry
>because i`m so confused and no ppl answer my question
>i has been write more and more code about my problems about the filter
>using checkbox
>and its doesnt work
>i hope you can tell me what code that must i have

Concentract less on posting code and more on telling us what
the problem is. If you don't mind me asking, what is your
native language?





>dokter cinta ( the fans of Microsoft Visual Basic)
>
>Jan Hyde wrote:
>> "dokter cinta" 's wild thoughts were
>> released on 21 Jun 2006 03:54:01 -0700 bearing the following
>> fruit:
>>
>> >this is the forms
>>
>>
>> Please read up on what muliposting is and why you should not
>> do it.
>>
>> J
>>
>>
>> Jan Hyde (VB MVP)
>>
>> --
>> Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.
>>
>> (Donna Eaker)


Jan Hyde (VB MVP)

--
Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.

(Donna Eaker)
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Wed Jun 21, 2006 2:43 pm    Post subject: Re: Help me about Filter Reply with quote

"Jan Hyde" wrote

> Concentract less on posting code and more on telling us what
> the problem is. If you don't mind me asking, what is your
> native language?

> >> Please read up on what muliposting is and why you should not
> >> do it.

It would be better to pick a group and keep all discussion focused there....

This same question has already been addressed in another group.

LFS
Back to top
View user's profile Send private message
dokter cinta



Joined: 04 Oct 2007
Posts: 42

PostPosted: Wed Jun 21, 2006 1:53 pm    Post subject: Re: Help me about Filter Reply with quote

sorry my native language is indonesia
i`m so sorry my speaking english was very bad

error message is ==> no value given for one or more required parameters
i dont know why
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 forms
http://www.geocities.com/joanleonz/forms.GIF

okay this is the code
===================================
Private Sub cmdfilter_Click()

Set rsdss = New Recordset
rsdss.ActiveConnection = con
rsdss.CursorType = adOpenStatic
rsdss.CursorLocation = adUseClient
rsdss.LockType = adLockOptimistic

start1 = DTPicker1.Value
start2 = DTPicker2.Value
driver = txtdriver.Text

strAddAnd = ""
strsql = "SELECT * FROM dss WHERE "

If Check1.Value = vbChecked Then
strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
(start2) & "'"
strAddAnd = " AND"
End If

If Check2.Value = vbChecked Then
strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
strAddAnd = " AND"
End If

If Check3.Value = vbChecked Then
strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
strAddAnd = " AND"
End If

If Check4.Value = vbChecked Then
strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
speed<='" & txtspeed2.Text & "'"
strAddAnd = " AND"
End If

If Check5.Value = vbChecked Then
strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
speed<='" & txtscore2.Text & "'"
strAddAnd = " AND"
End If
rsdss.Open strsql

Set datagrid1.DataSource = rsdss.DataSource

End Sub
=======================================




Jan Hyde wrote:
> "dokter cinta" 's wild thoughts were
> released on 21 Jun 2006 04:56:21 -0700 bearing the following
> fruit:
>
> >i`m so sorry
> >because i`m so confused and no ppl answer my question
> >i has been write more and more code about my problems about the filter
> >using checkbox
> >and its doesnt work
> >i hope you can tell me what code that must i have
>
> Concentract less on posting code and more on telling us what
> the problem is. If you don't mind me asking, what is your
> native language?
>
>
>
>
>
> >dokter cinta ( the fans of Microsoft Visual Basic)
> >
> >Jan Hyde wrote:
> >> "dokter cinta" 's wild thoughts were
> >> released on 21 Jun 2006 03:54:01 -0700 bearing the following
> >> fruit:
> >>
> >> >this is the forms
> >>
> >>
> >> Please read up on what muliposting is and why you should not
> >> do it.
> >>
> >> J
> >>
> >>
> >> Jan Hyde (VB MVP)
> >>
> >> --
> >> Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.
> >>
> >> (Donna Eaker)
>
>
> Jan Hyde (VB MVP)
>
> --
> Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.
>
> (Donna Eaker)
Back to top
View user's profile Send private message
Al Reid



Joined: 04 Oct 2007
Posts: 230

PostPosted: Wed Jun 21, 2006 5:34 pm    Post subject: Re: Help me about Filter Reply with quote

"dokter cinta" wrote in message @b68g2000cwa.googlegroups.com...
> sorry my native language is indonesia
> i`m so sorry my speaking english was very bad
>
> error message is ==> no value given for one or more required parameters
> i dont know why
> 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 forms
> http://www.geocities.com/joanleonz/forms.GIF
>
> okay this is the code
> ===================================
> Private Sub cmdfilter_Click()
>
> Set rsdss = New Recordset
> rsdss.ActiveConnection = con
> rsdss.CursorType = adOpenStatic
> rsdss.CursorLocation = adUseClient
> rsdss.LockType = adLockOptimistic
>
> start1 = DTPicker1.Value
> start2 = DTPicker2.Value
> driver = txtdriver.Text
>
> strAddAnd = ""
> strsql = "SELECT * FROM dss WHERE "
>
> If Check1.Value = vbChecked Then
> strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
> (start2) & "'"
> strAddAnd = " AND"
> End If
>
> If Check2.Value = vbChecked Then
> strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
> strAddAnd = " AND"
> End If
>
> If Check3.Value = vbChecked Then
> strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
> strAddAnd = " AND"
> End If
>
> If Check4.Value = vbChecked Then
> strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
> speed<='" & txtspeed2.Text & "'"
> strAddAnd = " AND"
> End If
>
> If Check5.Value = vbChecked Then
> strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
> speed<='" & txtscore2.Text & "'"
> strAddAnd = " AND"
> End If
> rsdss.Open strsql
>
> Set datagrid1.DataSource = rsdss.DataSource
>
> End Sub
> =======================================
>
>

Place a "Debug.Print strsql" just before the "rsdss.Open strsql" and post the result. Maybe I or someone can tell you what is going
wrong.

Also, you don't enclose numeric values with single quote marks ( ' ).

--
Al Reid
Back to top
View user's profile Send private message
dokter cinta



Joined: 04 Oct 2007
Posts: 42

PostPosted: Wed Jun 21, 2006 5:07 pm    Post subject: Re: Help me about Filter Reply with quote

yes sure
the wrong code in check2
because the check1 is run
but the error message tell no value given for one or required
parameters
so what happen about that?

Al Reid wrote:
> "dokter cinta" wrote in message @b68g2000cwa.googlegroups.com...
> > sorry my native language is indonesia
> > i`m so sorry my speaking english was very bad
> >
> > error message is ==> no value given for one or more required parameters
> > i dont know why
> > 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 forms
> > http://www.geocities.com/joanleonz/forms.GIF
> >
> > okay this is the code
> > ===================================
> > Private Sub cmdfilter_Click()
> >
> > Set rsdss = New Recordset
> > rsdss.ActiveConnection = con
> > rsdss.CursorType = adOpenStatic
> > rsdss.CursorLocation = adUseClient
> > rsdss.LockType = adLockOptimistic
> >
> > start1 = DTPicker1.Value
> > start2 = DTPicker2.Value
> > driver = txtdriver.Text
> >
> > strAddAnd = ""
> > strsql = "SELECT * FROM dss WHERE "
> >
> > If Check1.Value = vbChecked Then
> > strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
> > (start2) & "'"
> > strAddAnd = " AND"
> > End If
> >
> > If Check2.Value = vbChecked Then
> > strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
> > strAddAnd = " AND"
> > End If
> >
> > If Check3.Value = vbChecked Then
> > strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
> > strAddAnd = " AND"
> > End If
> >
> > If Check4.Value = vbChecked Then
> > strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
> > speed<='" & txtspeed2.Text & "'"
> > strAddAnd = " AND"
> > End If
> >
> > If Check5.Value = vbChecked Then
> > strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
> > speed<='" & txtscore2.Text & "'"
> > strAddAnd = " AND"
> > End If
> > rsdss.Open strsql
> >
> > Set datagrid1.DataSource = rsdss.DataSource
> >
> > End Sub
> > =======================================
> >
> >
>
> Place a "Debug.Print strsql" just before the "rsdss.Open strsql" and post the result. Maybe I or someone can tell you what is going
> wrong.
>
> Also, you don't enclose numeric values with single quote marks ( ' ).
>
> --
> Al Reid
Back to top
View user's profile Send private message
Al Reid



Joined: 04 Oct 2007
Posts: 230

PostPosted: Wed Jun 21, 2006 9:46 pm    Post subject: Re: Help me about Filter Reply with quote

Look, if you refuse to answers the questions asked of you and refuse to post
the SQL statement that you are generating, I really don't know how I, or for
that matter, anyone can help you. One more time. Place a Debug.Print
statement before the .Open and post back the actual string you are trying to
execute. With that, I think I can help. Without it I give up. It's up to
you.

--
Al Reid


"dokter cinta" wrote in message @c74g2000cwc.googlegroups.com...
> yes sure
> the wrong code in check2
> because the check1 is run
> but the error message tell no value given for one or required
> parameters
> so what happen about that?
>
> Al Reid wrote:
>> "dokter cinta" wrote in message
>> @b68g2000cwa.googlegroups.com...
>> > sorry my native language is indonesia
>> > i`m so sorry my speaking english was very bad
>> >
>> > error message is ==> no value given for one or more required parameters
>> > i dont know why
>> > 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 forms
>> > http://www.geocities.com/joanleonz/forms.GIF
>> >
>> > okay this is the code
>> > ===================================
>> > Private Sub cmdfilter_Click()
>> >
>> > Set rsdss = New Recordset
>> > rsdss.ActiveConnection = con
>> > rsdss.CursorType = adOpenStatic
>> > rsdss.CursorLocation = adUseClient
>> > rsdss.LockType = adLockOptimistic
>> >
>> > start1 = DTPicker1.Value
>> > start2 = DTPicker2.Value
>> > driver = txtdriver.Text
>> >
>> > strAddAnd = ""
>> > strsql = "SELECT * FROM dss WHERE "
>> >
>> > If Check1.Value = vbChecked Then
>> > strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
>> > (start2) & "'"
>> > strAddAnd = " AND"
>> > End If
>> >
>> > If Check2.Value = vbChecked Then
>> > strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
>> > strAddAnd = " AND"
>> > End If
>> >
>> > If Check3.Value = vbChecked Then
>> > strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
>> > strAddAnd = " AND"
>> > End If
>> >
>> > If Check4.Value = vbChecked Then
>> > strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
>> > speed<='" & txtspeed2.Text & "'"
>> > strAddAnd = " AND"
>> > End If
>> >
>> > If Check5.Value = vbChecked Then
>> > strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
>> > speed<='" & txtscore2.Text & "'"
>> > strAddAnd = " AND"
>> > End If
>> > rsdss.Open strsql
>> >
>> > Set datagrid1.DataSource = rsdss.DataSource
>> >
>> > End Sub
>> > =======================================
>> >
>> >
>>
>> Place a "Debug.Print strsql" just before the "rsdss.Open strsql" and post
>> the result. Maybe I or someone can tell you what is going
>> wrong.
>>
>> Also, you don't enclose numeric values with single quote marks ( ' ).
>>
>> --
>> Al Reid
>
Back to top
View user's profile Send private message
dokter cinta



Joined: 04 Oct 2007
Posts: 42

PostPosted: Wed Jun 21, 2006 11:17 pm    Post subject: Re: Help me about Filter Reply with quote

yes sure
i has been place debug.print mstrsql before rsdss.open mstrsql
this is the code

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

Debug.print mstrSQL

rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic
end sub

on check1.value = vbchecked is run like i want but after on
check2.value = vbchecked then the code is not running
error message is no value given for one or more required parameters
please help me
thanks





Al Reid wrote:
> Look, if you refuse to answers the questions asked of you and refuse to post
> the SQL statement that you are generating, I really don't know how I, or for
> that matter, anyone can help you. One more time. Place a Debug.Print
> statement before the .Open and post back the actual string you are trying to
> execute. With that, I think I can help. Without it I give up. It's up to
> you.
>
> --
> Al Reid
>
>
> "dokter cinta" wrote in message
> @c74g2000cwc.googlegroups.com...
> > yes sure
> > the wrong code in check2
> > because the check1 is run
> > but the error message tell no value given for one or required
> > parameters
> > so what happen about that?
> >
> > Al Reid wrote:
> >> "dokter cinta" wrote in message
> >> @b68g2000cwa.googlegroups.com...
> >> > sorry my native language is indonesia
> >> > i`m so sorry my speaking english was very bad
> >> >
> >> > error message is ==> no value given for one or more required parameters
> >> > i dont know why
> >> > 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 forms
> >> > http://www.geocities.com/joanleonz/forms.GIF
> >> >
> >> > okay this is the code
> >> > ===================================
> >> > Private Sub cmdfilter_Click()
> >> >
> >> > Set rsdss = New Recordset
> >> > rsdss.ActiveConnection = con
> >> > rsdss.CursorType = adOpenStatic
> >> > rsdss.CursorLocation = adUseClient
> >> > rsdss.LockType = adLockOptimistic
> >> >
> >> > start1 = DTPicker1.Value
> >> > start2 = DTPicker2.Value
> >> > driver = txtdriver.Text
> >> >
> >> > strAddAnd = ""
> >> > strsql = "SELECT * FROM dss WHERE "
> >> >
> >> > If Check1.Value = vbChecked Then
> >> > strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
> >> > (start2) & "'"
> >> > strAddAnd = " AND"
> >> > End If
> >> >
> >> > If Check2.Value = vbChecked Then
> >> > strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
> >> > strAddAnd = " AND"
> >> > End If
> >> >
> >> > If Check3.Value = vbChecked Then
> >> > strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
> >> > strAddAnd = " AND"
> >> > End If
> >> >
> >> > If Check4.Value = vbChecked Then
> >> > strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
> >> > speed<='" & txtspeed2.Text & "'"
> >> > strAddAnd = " AND"
> >> > End If
> >> >
> >> > If Check5.Value = vbChecked Then
> >> > strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
> >> > speed<='" & txtscore2.Text & "'"
> >> > strAddAnd = " AND"
> >> > End If
> >> > rsdss.Open strsql
> >> >
> >> > Set datagrid1.DataSource = rsdss.DataSource
> >> >
> >> > End Sub
> >> > =======================================
> >> >
> >> >
> >>
> >> Place a "Debug.Print strsql" just before the "rsdss.Open strsql" and post
> >> the result. Maybe I or someone can tell you what is going
> >> wrong.
> >>
> >> Also, you don't enclose numeric values with single quote marks ( ' ).
> >>
> >> --
> >> Al Reid
> >
Back to top
View user's profile Send private message
Al Reid



Joined: 04 Oct 2007
Posts: 230

PostPosted: Thu Jun 22, 2006 11:16 am    Post subject: Re: Help me about Filter Reply with quote

Great! Now copy the printed string from the immediate window and paste it into your reply so that I can see it. I feel like we are
playing hide and seek.

--
Al Reid


"dokter cinta" wrote in message @c74g2000cwc.googlegroups.com...
> yes sure
> i has been place debug.print mstrsql before rsdss.open mstrsql
> this is the code
>
> 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
>
> Debug.print mstrSQL
>
> rsdss.Open mstrSQL, con, adOpenStatic, adLockOptimistic
> end sub
>
> on check1.value = vbchecked is run like i want but after on
> check2.value = vbchecked then the code is not running
> error message is no value given for one or more required parameters
> please help me
> thanks
>
>
>
>
>
> Al Reid wrote:
> > Look, if you refuse to answers the questions asked of you and refuse to post
> > the SQL statement that you are generating, I really don't know how I, or for
> > that matter, anyone can help you. One more time. Place a Debug.Print
> > statement before the .Open and post back the actual string you are trying to
> > execute. With that, I think I can help. Without it I give up. It's up to
> > you.
> >
> > --
> > Al Reid
> >
> >
> > "dokter cinta" wrote in message
> > @c74g2000cwc.googlegroups.com...
> > > yes sure
> > > the wrong code in check2
> > > because the check1 is run
> > > but the error message tell no value given for one or required
> > > parameters
> > > so what happen about that?
> > >
> > > Al Reid wrote:
> > >> "dokter cinta" wrote in message
> > >> @b68g2000cwa.googlegroups.com...
> > >> > sorry my native language is indonesia
> > >> > i`m so sorry my speaking english was very bad
> > >> >
> > >> > error message is ==> no value given for one or more required parameters
> > >> > i dont know why
> > >> > 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 forms
> > >> > http://www.geocities.com/joanleonz/forms.GIF
> > >> >
> > >> > okay this is the code
> > >> > ===================================
> > >> > Private Sub cmdfilter_Click()
> > >> >
> > >> > Set rsdss = New Recordset
> > >> > rsdss.ActiveConnection = con
> > >> > rsdss.CursorType = adOpenStatic
> > >> > rsdss.CursorLocation = adUseClient
> > >> > rsdss.LockType = adLockOptimistic
> > >> >
> > >> > start1 = DTPicker1.Value
> > >> > start2 = DTPicker2.Value
> > >> > driver = txtdriver.Text
> > >> >
> > >> > strAddAnd = ""
> > >> > strsql = "SELECT * FROM dss WHERE "
> > >> >
> > >> > If Check1.Value = vbChecked Then
> > >> > strsql = strsql & " date >='" & (start1) & "'" & "AND date <='" &
> > >> > (start2) & "'"
> > >> > strAddAnd = " AND"
> > >> > End If
> > >> >
> > >> > If Check2.Value = vbChecked Then
> > >> > strsql = strsql & strAddAnd & " driver='" & (driver) & "'"
> > >> > strAddAnd = " AND"
> > >> > End If
> > >> >
> > >> > If Check3.Value = vbChecked Then
> > >> > strsql = strsql & strAddAnd & " groups='" & cbogroups.Text & "'"
> > >> > strAddAnd = " AND"
> > >> > End If
> > >> >
> > >> > If Check4.Value = vbChecked Then
> > >> > strsql = strsql & strAddAnd & " speed >='" & txtspeed1.Text & "' AND
> > >> > speed<='" & txtspeed2.Text & "'"
> > >> > strAddAnd = " AND"
> > >> > End If
> > >> >
> > >> > If Check5.Value = vbChecked Then
> > >> > strsql = strsql & strAddAnd & " score >='" & txtscore1.Text & "' AND
> > >> > speed<='" & txtscore2.Text & "'"
> > >> > strAddAnd = " AND"
> > >> > End If
> > >> > rsdss.Open strsql
> > >> >
> > >> > Set datagrid1.DataSource = rsdss.DataSource
> > >> >
> > >> > End Sub
> > >> > =======================================
> > >> >
> > >> >
> > >>
> > >> Place a "Debug.Print strsql" just before the "rsdss.Open strsql" and post
> > >> the result. Maybe I or someone can tell you what is going
> > >> wrong.
> > >>
> > >> Also, you don't enclose numeric values with single quote marks ( ' ).
> > >>
> > >> --
> > >> Al Reid
> > >
>
Back to top
View user's profile Send private message
Jan Hyde



Joined: 04 Oct 2007
Posts: 1211

PostPosted: Thu Jun 22, 2006 5:04 pm    Post subject: Re: Help me about Filter Reply with quote

"dokter cinta" 's wild thoughts were
released on 21 Jun 2006 19:17:54 -0700 bearing the following
fruit:

>yes sure
>i has been place debug.print mstrsql before rsdss.open mstrsql
>this is the code
>
>bAtLeastOne = False
>mstrSQL = "SELECT * from dss WHERE "
>

and you don't see the problem?

Do understand SQL? If not your going to stuggle a great
deal.

J

Jan Hyde (VB MVP)

--
Many a women who thinks she has purchased a dress for the ridiculous price has actually bought it for an absurd figure.

(Donna Eaker)
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Thu Jun 22, 2006 11:14 am    Post subject: Re: Help me about Filter Reply with quote

"Al Reid" wrote
> Great! Now copy the printed string from the immediate window and paste it into your reply so that I can see it. I feel like
we are
> playing hide and seek.

The same thing is going on in General Discussion, with the same results.

I'd suggest we drop this thread and move to the other group, but with
the language barrier nearly insurmountable, there will be few who will
want to continue a discussion that turns out to be a game of Twenty
Questions...

LFS

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group