G
Guest
I have a query based on the Employees table. The query is sorted by
LastName, and is used as the record source for an Employees form. One of the
fields is a check box bound to a Yes/No field named Inactive, which is used
to indicate employees who no longer work here, but who appear in records we
need to keep. The form's Open event is:
Me.RecordSource = "SELECT * FROM qryEmployee WHERE Inactive = False ORDER BY
LastName"
I have added some buttons to the form to change the sort order to
Department, etc., using code in the Click event similar to the above.
One of the buttons is to show all employees, both current and inactive. I
do this with Me.RecordSource = "SELECT * FROM qryEmploye"
Other command buttons re-apply the Inactive filter. In most cased the
alphabetical listing will be used, but the others are necessary sometimes.
Now the questions. I started by filtering out Inactive employees with the
query, but could not figure out a good way to show all employees. Also, for
the query I used the asterisk, then added LastName for ordering and Inactive
for the criteria, but then in the VBA SELECT statements I needed to specify
the table for the Inactive field. Apparently it is either that or not use
the asterisk in the query design. Is one approach preferable to another
(filter by query vs. filter by code) in a situation like this? Are there
positives and negatives to using the asterisk in query design? If I filter
in the query is there a way to remove that filter in the form?
The SELECT statement is sometimes more complex than the illustration above.
I have been using strSQL = "SELECT * ...", then Me.RecordSource = strSQL, but
I cannot figure out how to wrap the SELECT statement in the code window. I
tried the usual things for a text string (underscores, concatenation), but it
didn't work. I'm probably missing something simple, but those are sometimes
the hardest to see.
LastName, and is used as the record source for an Employees form. One of the
fields is a check box bound to a Yes/No field named Inactive, which is used
to indicate employees who no longer work here, but who appear in records we
need to keep. The form's Open event is:
Me.RecordSource = "SELECT * FROM qryEmployee WHERE Inactive = False ORDER BY
LastName"
I have added some buttons to the form to change the sort order to
Department, etc., using code in the Click event similar to the above.
One of the buttons is to show all employees, both current and inactive. I
do this with Me.RecordSource = "SELECT * FROM qryEmploye"
Other command buttons re-apply the Inactive filter. In most cased the
alphabetical listing will be used, but the others are necessary sometimes.
Now the questions. I started by filtering out Inactive employees with the
query, but could not figure out a good way to show all employees. Also, for
the query I used the asterisk, then added LastName for ordering and Inactive
for the criteria, but then in the VBA SELECT statements I needed to specify
the table for the Inactive field. Apparently it is either that or not use
the asterisk in the query design. Is one approach preferable to another
(filter by query vs. filter by code) in a situation like this? Are there
positives and negatives to using the asterisk in query design? If I filter
in the query is there a way to remove that filter in the form?
The SELECT statement is sometimes more complex than the illustration above.
I have been using strSQL = "SELECT * ...", then Me.RecordSource = strSQL, but
I cannot figure out how to wrap the SELECT statement in the code window. I
tried the usual things for a text string (underscores, concatenation), but it
didn't work. I'm probably missing something simple, but those are sometimes
the hardest to see.