On Thu, 13 Jan 2005 09:13:06 -0800, Mark05
Answers inline.
Thanks John but I think I need to explain it more. I know you can use querys
in a form but I need to have values I can change and store as well as add new
rows.
No problem. Many, many queries are updateable. If you are assuming
that you must base a form on a Table to update it or add new rows,
RETHINK THAT ASSUMPTION; it's wrong. There are other tools as well;
see below.
my question is this.
Can I create a table (A) where I can specify a look up value for a field.
Of course. It's perfectly routine.
This look up value comes from another table (B), however I need to have a
WHERE clause or filter the return values based on a field in the current
table (A) that the look up field is in. So lets say table B contains the
following rows
ID Name value
1 Tom 65
2 Tom 44
3 Frank 22
4 Tom 88
So now in my table A I am adding a new row and here are the fields
ID Name Value
Your TableA *SHOULD NOT CONTAIN* either Name or Value. Storing that
information redundantly is neither necessary nor is it good design!
TableA should store the ID, and any needed information about TableA's
use of that value.
What I want to do is for the value field have the ability based on the name
I put in to see the values from table B that only apply to the Name entered
and not ALL the values from table B which will show up if my look up SQL
looks like SELECT values FROM table B
So Here is what I enter in table A
ID Name Value
7 Tom
My choices for my look up for the Value field should show
65 44 and 88 and not show 22
I hope this is clearer
mark
Stop thinking that you need a different Table for everything! You
don't.
Create a Form based on TableA. Put a Combo Box control (a "lookup"
tool, but it is NOT necessary to use a Table Lookup to create one!) on
the form based on a Query. Create this Query by adding TableB to the
query design window; select only the name field (and hope there aren't
two people named Tom in your system); set the query's Unique Values
property to True. Now create a Combo Box on your form based on this
query; this will give you a "lookup" on the form showing each name
only once. Let's say your form is named MyForm and the combo box is
named cboName.
Now create another query also based on TableB. Select the Name and
Value fields. As a criterion on the Name field put
=[Forms]![MyForm]![cboName]
This will filter this query to show only the values for the name
currently selected in cboName. Let's call this combo cboValue.
You'll need one additional thing: view the Properties of cboName; on
the Events tab select the AfterUpdate event. Click the ... icon and
choose the Code Builder. Access will put you into the VBA editor with
the Sub and End Sub lines; just add the line in between:
Private Sub cboName_AfterUpdate()
Me!cboValue.Requery
End Sub
This will "wake up" cboValue to the fact that its criteria have
changed.
John W. Vinson[MVP]