Cats and Dogs

depawl

Registered User.
Local time
Today, 12:08
Joined
May 19, 2007
Messages
144
OK, I'm designing a form that will allow me to select one or more fields from a table, and then print a report depending on the value of the selected field(s) sorted by date.
For example, say I have a table with the fields:
Name | Cat | Dog | Age
Cat and Dog are yes/no fields.
So on my form let's say I select Cat.
On the report I want all the records with a Cat value of yes, sorted by their age.
Doesn't seem like it should be that difficult but I've been playing around with it for awhile and don't seem to be getting anywhere.
Thanks.
 
Why not have the record source for your report be a query that you can set the criteria in the Cat field to Yes.
 
What I'm trying to do is to be able to select the field (not the record) on a form. (i.e. I need a combobox that lists the fields in the table (and not records for a given field)). So then I can select the field(s) I want in my report ("Cats" in my example) and then run a report for "Cats" with a value of "Yes". In actuality I could be selecting several fields at once.
 
Thanks. I've been playing around with that for a week, but don't seem to be able to get it.
Here's where I'm at.
On my form, I have a combobox with the Row Source Type set to Field List. In my simplified example, I can then select either "Cats" or "Dogs" from the dropdown field list in the combobox. What I can't figure out is how to filter that selection. For example for records where there is a "1" in the "Cats" field (the 1 indicates a Yes, 0 would indicate No).
Thanks again.
 
Time to post a sample database so that it can be analyzed. Click on the Go Advanced button in the quick reply window and follow the wizard.
 
I didn't get a Wizard after I selected Go Advanced, but hopefully I did it right.
As you can see I have a table and a form. On the form I have a combobox with field list as it's Row Source Type.
So for example if I select "Cats" in the combo box, I would like to be able to get a report filtered with only the Cat's names:

Fluffy
Barney

And vice versa for Dogs.

Once again, this is a very simplistic example of my actual database, but this is the basics of what I need.
Thanks very much.
 

Attachments

It would be easier if you treated the selection of the fields to display and the selection of which records to display as seperate exercises.

Have a field, [AnimalType] maybe, that makes reference to the type of animal. If the data is normalised this would contain a code that refers to a record in another able containing the name of the animal. By having two fields, as you have now, you risk stating that an animal is a cat as well as being a dog unless you have checks on your data maintenance form to prohibit this. By employed the suggested method you will also be able to introduce other animals to the application easily.

Have a Multi Select listbox where you select the fields to display and then another where you select which records to display by animal type. This second listbox could be Multi Select as well.

Trawl through the two listboxes (selected items only) to build the query string and the where clause.
 

Users who are viewing this thread

Back
Top Bottom