A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using Lookup Query with Calculated Value in Table ComboBox



 
 
Thread Tools Display Modes
  #1  
Old April 14th, 2010, 10:51 PM posted to microsoft.public.access.tablesdbdesign
Matthew Pfluger[_2_]
external usenet poster
 
Posts: 36
Default Using Lookup Query with Calculated Value in Table ComboBox

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
  #2  
Old April 14th, 2010, 11:46 PM posted to microsoft.public.access.tablesdbdesign
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Using Lookup Query with Calculated Value in Table ComboBox

I have done this with text boxes but have not tried with combo --

Use a text box for first and last name and combo box with AutoExpand on top
of the text box. Set the BackStyle and BorderStyle property of combo to
transparent.

Create a macro with two SetValue actions.
First sets the text box with first and last name.

Second sets combo box - Null

Set AfterUpdate property of combo box to call the macro.



--
Build a little, test a little.


"Matthew Pfluger" wrote:

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

  #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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.