CheckBox for data criteria

  • Thread starter Thread starter Igor G.
  • Start date Start date
I

Igor G.

I have table with data for last few years and opening is terribly slow. I
want to display data for only one month, or if user want to view all data
must check checkbox to enable this.

Example:
I have "main" form Form1 with Check1. If Check1 is not checked all subforms
display data for only one month (or last 30 days). If Check1 is checked,
subforms display all data. In query is field for short Date and Time.
Thanks!
 
Igor G. said:
I have table with data for last few years and opening is terribly slow. I
want to display data for only one month, or if user want to view all data
must check checkbox to enable this.

Example:
I have "main" form Form1 with Check1. If Check1 is not checked all
subforms
display data for only one month (or last 30 days). If Check1 is checked,
subforms display all data. In query is field for short Date and Time.
Thanks!


Here's an example using one of my own tables and a test form ...

SELECT *
FROM Buddies
WHERE [LastContact] BETWEEN DateSerial(Year(Date()),Month(Date()),1) AND
DateSerial(Year(Date()),Month(Date())+1,0)
OR Forms!frmTest!chkTest.Value <> 0

.... where "Buddies" is the table being queried, "LastContact" is the
Date/Time field, "frmTest" is the form containing the check box, and
"chkTest" is the check box.

The SQL could be simplified by using "WHERE Month([LastContact]) =
Month(Date()) but that would prevent the database engine from using any
index that might exist on the Date/Time field.
 
Back
Top