Re: Tying check boxes to data
- From: BTU_needs_assistance_43 <BTUneedsassistance43@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Jul 2009 06:23:01 -0700
Specifically I want to exclude the column of data that the check box
represents if the box is not checked. I tried your code and played with it a
fair bit but for unknown reasons it cause a compile error in one of my early
on query expressions and wont let the data go through blanking out my chart
completely and no matter how I try to rewrite the equations they still wont
compile although as soon as I remove the module and code it works like a
charm again. I'm gonna keep playing with the code and trying to write
something into the criteria, but if you have any ideas on this or other code
I'd gladly take them.
"Dale_Fye via AccessMonster.com" wrote:
You indicate that each checkbox represents an entire column of data. Do I.
understand that you want to exclude entire columns from the query results if
the checkbox is not checked? If so, you are going to need to build the SQL
string dynamically. Start out by writing a function that builds the string
dynamically, something like:
Public fnBuildSQL() as String
dim frm as Form
Dim strSQL as string
set frm = Forms("yourFormName")
strSQL = "SELECT [Field1], [Field2], " _
& (iif(frm.check1, [Field3], NULL) + ", ") _
& (iif(frm.check2, [Field4], NULL) + ", ") _
& (iif(frm.check3, [Field5], NULL) + ", ") _
& (iif(frm.check4, [Field6], NULL) + ", ") _
& (iif(frm.check5, [Field7], NULL) + " ")
if Right(strSQL, 2) = ", " Then
strSQL = left(strSQL, len(strSQL) - 2)
end if
strSQL = strSQL & "FROM yourTable " _
& "WHERE [SomeField] = " & frm.Combo2
fnBuildSQL = strSQL
End Function
Then, in the AfterUpdate event of the checkboxes (or in a command button -
cmdRequery) you can call this function and set the Record Source of the form,
subform, or report that contains the graph to this value. Something like:
Private Sub Check1_AfterUpdate
me.subGraph.form.RecordSource = fnBuildSQL
End Sub
BTU_needs_assistance_43 wrote:
Your on the right track but I dont think this is simple enough to write into
that line. Each check box of mine represents an entire column of data with 5
various values within each set of data. Also what combo box 2 displays is
completely dependent on the selection made it combo box 1, where combo box 1
displays a constant list of choices. When I check one of the check boxes I
want it to display all the data associated with it, and if unchecked to hide
all that data. I've tried things like writing into the criteria section
[myForm]![Check1] = True
or IIf([Check1] = True, [myTable]![Section], *)
For the first one it will either blank out the entire graph or allow the
entire graph if i check any of the check boxes. Its just frustrating!
One way would be something like:[quoted text clipped - 36 lines]
the data shown to where it matched the combo boxes. How do I make the query
only show the data from the boxes which I have checked?
--
HTH
Dale Fye
Message posted via http://www.accessmonster.com
- Follow-Ups:
- Re: Tying check boxes to data
- From: Dale_Fye via AccessMonster.com
- Re: Tying check boxes to data
- References:
- Tying check boxes to data
- From: BTU_needs_assistance_43
- Re: Tying check boxes to data
- From: Dale_Fye via AccessMonster.com
- Re: Tying check boxes to data
- From: BTU_needs_assistance_43
- Re: Tying check boxes to data
- From: Dale_Fye via AccessMonster.com
- Tying check boxes to data
- Prev by Date: Re: New Password
- Next by Date: Re: New Password
- Previous by thread: Re: Tying check boxes to data
- Next by thread: Re: Tying check boxes to data
- Index(es):
Relevant Pages
|