Walt wrote:
Ken, Philip, John, and Gina - thank you all. I truly apprecaite the help
this forum and class act people like youselves provide; especially to those
of us still learning access but being asked to develop databases that go
beyond our capabilities.
Based on the comments, I broke the tables out. Here's what I did and I hope
my explanations make more sense. I now have 10 tables. Here's the names and
columns:
1)Plan1: Plan1ID, Description
2)Plan2: Plan2ID, Description
3)Plan3: Plan3ID, Description
4)Sources: SourceID, Description
5)Recommendations: RecID, Description
6)Accomplishments: AccID, Description, Impact, Obstacles, Next Steps
7)POC: POCID, 1stName, LastName, Title, Office, Phone, Email
8)Junction_Master
![Stick Out Tongue :P :P](/styles/default/custom/smilies/tongue.gif)
lan1ID, Plan2ID, Plan3ID, SourceID, RecID,AccID, POCID
(My thinking was I need a table that relates all of the IDs together to make
querying easier - is that necessary?)
9)Junction_Plans: Plan1ID, Plan2ID, Plan3ID (this table is a cross reference
of the plans. For example: Plan1ID01 is the same as Plan2ID01,02,03 and
Plan3ID01 - 10
I created this table to try to ref the ID numbers in the master table so I
can query and pull the description of all plans that relate to a given
recommendation and/or accomplishment
10)Junction_SRA:SourceID,RecID, AccID (Not sure I need this table)
Here's what I'm trying to do. My database needs to allow a POC to input a
recommedation or accomplishment or both. The POC should be able to tell me
what plan the rec / acc ties into and based on their selection I should be
able to run a report that automatically pulls the other plans that coincide.
A recommendation will not always have an accomplishment and vice versus.
Also, not all rec/acc will have POCs which I think stops me from being able
to use autonumbers so I'm using text boxes for the IDs. I have set-up any of
the data entry forms yet, thinking that since i have a lot of information
already it would be better to get the search function working so I can pull
reports to give to my bosses now...and buy me some time.
Thank you all again for all the help because I truly need it.
:
Probably the easiest way is to base your report on a query which references
the various control on the form as parameters. You can make a parameter
optional by testing for 'OR <parameter> IS NULL' in the query, so your query
would be something like this:
SELECT *
FROM [Reports_Plans]
WHERE
([Report_Plan] = Forms![YourForm]![cboReport_Plan]
OR Forms![YourForm]![cboReport_Plan] IS NULL)
AND
([Rec] = Forms![YourForm]![txtRecommendation]
OR Forms![YourForm]![txtRecommendation] IS NULL)
AND
([Acc] = Forms![YourForm]![txtAccomplishment]
OR Forms![YourForm]![txtAccomplishment] IS NULL);
The underlying logic regarding the restriction of the results on the
recommendations and accomplishments is not entirely clear from your post.
The above uses a Boolean AND operation which means that if both a
recommendation and accomplishment parameter are entered in the form a row
would be returned only where it contains both of the parameter values.
Also its not clear whether the values of the rec and acc columns are the
keywords per se, or if the keywords are substrings within the values in these
fields. If the latter you'd use the LIKE operator with wildcards rather than
the = equality operator:
SELECT *
FROM [Reports_Plans]
WHERE
([Report_Plan] = Forms![YourForm]![cboReport_Plan]
OR Forms![YourForm]![cboReport_Plan] IS NULL)
AND
([Rec] LIKE "*" & Forms![YourForm]![txtRecommendation] & "*"
OR Forms![YourForm]![txtRecommendation] IS NULL)
AND
([Acc] LIKE "*" & Forms![YourForm]![txtAccomplishment] & "*"
OR Forms![YourForm]![txtAccomplishment] IS NULL);
I'd strongly recommend that you design and save the query in SQL view, not
design view, as you'll find that if you use the latter Access will move
things around a lot after you save it and it will be less easy to make any
amendments to the query.
To hide/show the Recommnedations and/or Accomplishments in the report add
code to the Format event procedure of the report header to hide/show the
controls bound to these fields:
Me.[acc].Visible = Forms![YourForm]![chkShowAcc]
Me.[rec].Visible = Forms![YourForm]![chkShowRec]
You'll need to change the table, fields, form and control names in the above
to your real ones of course.
The 'Go' button on the form simply needs to open the report.
Take note of what Phil has said about the possible need to decompose your
table into related tables. It doesn't affect the above, however, as if the
table is decomposed the query would simply be based on both tables joined,
rather than on the one.
Ken Sheridan
Stafford, England
:
Hi,
I have to create a search form that is harder than what I know how to do.
The page needs to have the following:
1 - Reports/Plans [drop down list]
2 - Recommendation [keyword search on the rec column]
*if Report/Plan is selected then search is only on that item, otherwise
entire column)
3 - Accomplishment [keyword search on the acc column]
*if Report/Plan is selected then search is only on that item, otherwise
entire column)
4 - Results Should inlcude:
Recommendations [check box] (if checked rec's show in report)
Accomplishments [check box] (if checked acc's show in report)
(if both are checked then both show in the report)
Go [button] once clicks returns report based on selections
Reports/plans is a table by itself.
Recommnedations and Accomplishments are in the same table.
I'm hoping this is easier to do than what I'm making it. I appreciate any
assistance.
Thank you
I'm afraid I'm baffled by your terminology, and can't get a handle on
what these things are. A POC is a person, right?
An autonumber field is a convenient way of making records unique, but
the value shouldn't be used any other way than to refer to a record. I
don't think there's any reason not to use one - managing IDs manually is
likely to be error-prone.
I've grave misgivings about the three different "Plan" tables. If the
names are so similar then the "entities" are likely to be similar enough
to be in the same table.
Why not tell us in plain language what these various things are, and
what their relationships are in the real world, and then we'll see what
table structure you need?
Be reassured; this is the hardest bit! Get your tables right and
everything else is downhill. The converse is also true!
Phil