View Single Post
  #3  
Old April 24th, 2010, 12:48 AM posted to microsoft.public.access.tablesdbdesign
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Using Lookup Query with Calculated Value in Table ComboBox

Matthew

I may be mis-reading your description ... if so, my comments won't apply ...

It sounds like you are trying to work directly in the tables, and using the
Lookup data type.

If so, that's your first and second mistakes.

Access tables only store data. Access forms display data and offer a rich
event environment so you can better control how and when data is displayed.
Besides, in a well-normalized table structure, the foreign key fields will
be mostly meaningless numbers (if you're using Access Autonumbers for your
primary key fields). That's one...

The lookup data type stores the key value, but displays something else, the
looked-up value. This proves confusing over and over again. It also
encourages working directly in the tables. Instead, use a combobox in a
form. This way, what is stored in the underlying table is the value of the
key, and that's what shows.

But hey! I might be reading too much into what you posted...g

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.



"Matthew Pfluger" wrote in
message ...
Hello all,

This question takes a complicated setup, but I'll try to keep it brief. I
have a database with a main table (tblMain) and a lookup table
(tblLookup).
tblMain has an integer field (LookupMe) that is related to the ID field in
tblLookup. I set up LookupMe to use a ComboBox input display control that
uses a query as its source. The query contains two columns: tblLookup.ID
and
a calculated value, say "[First Name] & " " & [Last Name]". Back in
tblMain,
the LookupMe field has the following properties:

Bound Column: 1
Column Count: 2
Column Heads: No
Column Widths: 0";3"
Limit to List: Yes
Allow Value List Edits: No

So, I've set up normalized tables and set up a ComboBox with a lookup
query
that stores the ID, but displays the calculated value. Great, right?
Well,
I can store and modify records, but when I try to use the AutoFilter
feature
in tblMain's Datasheet view on the LookupMe field, I get the error "Syntax
error in query. Incomplete query clause." After playing around for a
while,
I determined that the calculated value is the problem. When I redo the
LookupMe field's ComboBox's RecordSource to not display a calculated
value,
the Autofilter feature works.

I can workaround this by finding another way to display data, but
sometimes
I really want to display a calculated value. I would really appreciate it
if
someone else can verify this problem and see if they can find a solution
or
workaround.

Thanks for your help,
Matthew