473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

lookup questions

I've been reading about how evil Lookup fields in tables are, but I've got
to be missing something really basic. I know this subject has been covered
before, because I've just spent an hour or two reading about it on google,
but there is something I still don't understand, and I'm hoping someone will
be willing to explain it to me in small words.

Let's say I have a table for addresses, and it includes a field for state.
What I would normally do is create a table of state abbreviations and use
the lookup wizard to link to it. Then, when I make a form for data entry
based on the address table, the field for states appears as a drop down
list.

So, what happens if I don't do the lookup table for "state"? I assume I
still need a table of state abbreviations, but ... how do I get the
information from my state table into my address table? What actually winds
up "in" the address table state field? Just text?

What I'm afraid of is that the answer somehow involves using visual basic to
take the info from the form and put it into the address table, rather than
directly updating the table from the form. And I don't know visual basic.
Does this mean I'm doomed to crappy design until I learn it?

Thanks for any clarification anyone wants to provide....

Nov 13 '05 #1
3 2894
Did you follow the track to www.mvps.org/access ? If not, it's worth a peek

Having a lookup table with the state codes is a great idea but you get at it
with the query for your combobox on the form rather than having it percolate
up as an artifact of a table. You have exactly the same access to your data
and in exactly the same form.

Now consider the case where you are attempting to include the state
information in a query that you've designed based on a table with a lookup
field as you describe. The query you're designing won't return the value
for a state. Try it. The lucky people who asked about lookup fields and,
having been told to avoid them, plunged ahead anyway will discover the
problems early and take remedial action. Most novices don't discover their
problem until very late in the day. They put in the lookup fields because
they looked like a lot of free functionality and it's impressive as can be
to have something so cool to show off. As time goes on they spend more
effort making their applications more useful. Their early forms aren't too
sophisticated and they probably don't even bother to create reports. As
they start to create more sophisticated forms and queries and reports
they're going to discover that the queries that make everything else work
seem not to work too well. There are some fields that return garbage or
nothing at all. Guess which fields. Some hardworking and creative types
will come up with ingenious work-arounds but, in time, nothing can overcome
the flaw. The longer it takes to come to that realization the worse the
reckoning. The only way to correct the problem is to go back and correct
the tables. Now just about every form and query that used the affected
tables will have to be changed to get the required functionality. I could
go on.

If you haven't heard it before, may I be the first to tell you that the
cornerstone of a good application is good data design - identifying and
representing the entities that play in your application space - the tables!
Get them right and everything else is possible and surprisingly easy. How
do you get them right? Get to know what you're trying to represent and then
design your tables obeying the relational rules. So help me, Codd! [E.F.
Codd and C. J. Date; heavy hitting IBMers circa 1970 - think of DB2].
There are rules of Normalization where your tables are concerned. Third
Normal Form is pretty much the minimum standard for most applications. If
you don't know what that means then you'll probably go back to "touch up"
the Access work you've done before learning.

If you just googled the words "lookup field" in all of the Access newsgroups
then you probably saw a thread on microsoft.public.access in which I'm
involved. Did you see where the other person wrote
"AAAAAAAAAAHHHHHHHHHHHHHHHH!"? He'd been warned about lookup fields, used
them anyway, was having troubles with a query that just wouldn't work and I
said I wouldn't try to help him further until he got rid of the lookup
fields.

After more carefully re-reading your post, I have a feeling that you may
have confused Lookup Fields in tables with "lookup tables". Lookup tables
are a good thing. They are just normal tables with some meaningful list
that is held for reference. I think you used the term Lookup Wizard when
you were actually referring to the Combobox Wizard. Yup. When you have
wizards enabled on the Toolbox then placing a combobox on your Form (not
Table) will cause it to spring to life and ask what you want to do.

Nomenclature is important. Fields only occur in tables. The things on
forms are Controls. Controls can be bound to fields. Lots of folks use the
terms as though they were interchangeable. They aren't.

Lookup tables good; Lookup Fields BAD. All is well.

My other favorite rant is about the mis-use of the Autonumber type. You can
google for it or find it on www.mvps.org/access

HTH
--
-Larry-
--

"my-wings" <my******@TAKEOUTatt.net> wrote in message
news:fq*********************@bgtnsc05-news.ops.worldnet.att.net...
I've been reading about how evil Lookup fields in tables are, but I've got
to be missing something really basic. I know this subject has been covered
before, because I've just spent an hour or two reading about it on google,
but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small words.

Let's say I have a table for addresses, and it includes a field for state.
What I would normally do is create a table of state abbreviations and use
the lookup wizard to link to it. Then, when I make a form for data entry
based on the address table, the field for states appears as a drop down
list.

So, what happens if I don't do the lookup table for "state"? I assume I
still need a table of state abbreviations, but ... how do I get the
information from my state table into my address table? What actually winds
up "in" the address table state field? Just text?

What I'm afraid of is that the answer somehow involves using visual basic to take the info from the form and put it into the address table, rather than
directly updating the table from the form. And I don't know visual basic.
Does this mean I'm doomed to crappy design until I learn it?

Thanks for any clarification anyone wants to provide....

Nov 13 '05 #2

"Larry Daugherty" <La********************@verizon.net> wrote in message
news:FO****************@nwrddc02.gnilink.net...
Did you follow the track to www.mvps.org/access ? If not, it's worth a peek

Yep. I actually googled the words "access lookup field evil" (without the
quotes) and it's the top entry. All the reasons not to use lookup fields
were there. But I still don't understand what to use instead.

Having a lookup table with the state codes is a great idea but you get at it with the query for your combobox on the form rather than having it percolate up as an artifact of a table. You have exactly the same access to your data and in exactly the same form.
But this is the part I don't get. How does the data get from the combo box
on the form back into your table? And what is recorded in the table? I
still have this field called "state"....how does it get any information into
it, and what kind of information is there? I understand the solution is
queries and combo boxes on forms, but I don't understand how things are
hooked together if there is no lookup field in the table.

After more carefully re-reading your post, I have a feeling that you may
have confused Lookup Fields in tables with "lookup tables".
No. I was referring to the Lookup Field you get in a table when you select
Lookup Wizard from the data types.
Lookup tables
are a good thing. They are just normal tables with some meaningful list
that is held for reference. I think you used the term Lookup Wizard when
you were actually referring to the Combobox Wizard.
Nope. Was referring to the Lookup wizard available in table design, not the
one that creates combo boxes on forms.
Lookup tables good; Lookup Fields BAD. All is well.


Or all will be well when I figure out what to use instead of lookup fields,
lol.

I appreciate your reply, but as you can see, I'm still puzzling over this.
I'm working my way through a book called Microsoft Office Access 2003 Inside
Out. I'm only on Chapter 5, so maybe things will clarify themselves as I
proceed. Right now, it looks like in the places I would have put lookup
fields, the author used the relationship builder to show a connection
between the regular table and the lookup table. When I look at the tables
with data, there are no drop down lists. Just the data itself.

Excuse me a minute while I go build a quick form.....

Back with an "ah ha!". Let's see if I have this right:

1. Create tblAddresses with a "state" field.
2. Create tlkpStates with its "state" field.
3. Go to Tools/Relationships and add both tables.
4. Drag the tblAddresses "state field" to tlkpStates "state field" and
create a many-to-one relationship.
5. Create a form.
6. Use the combo box wizard to create a combo box from tlkpStates. At the
appropriate screen, say that you want to store the result in tblAddresses
"state" field.

Then, as long as you use the form to enter things, the only things in the
tblAddresses "states" field will be entries from tlkpStates. On the other
hand, if someone were to enter directly in the table, there would be no
protection that the entry exists in the tlkpStates. Which is why you can't
let people enter things directly in tables, I'll bet.

I hope I have this right finally. The above looks like what everyone has
been saying, but without working my way through the combo box wizard, I
didn't see where the "connection" was being made.

I think I'm marginally less confused now, but hopefully someone will let me
know if I still don't understand this correctly.

Thanks.

Alice
Nov 13 '05 #3
The RowSource of your Combo Box could have the "stateid" and "statename"
fields, in that order. If you set the bound field as the "stateid" field (in
the wizard or the ComboBox properties) but set its width to 0, the user will
see the state's name, but the stateid will be stored in your table.

To retrieve the state name with your data, you join the primary table to the
state table on stateid and pull down into the Query Builder grid the
statename from the state Table.

FYI, for "stateid" in my state lookup table, I use the USPS state code, eg.,
AK for Alaska, AR for Arkansas, ... TX for Texas, etc. That's because I want
to show it to the user and may want to use that field in some uses (e.g., an
address report or printing envelopes or mailing labels). If I had no need to
use the field, I could use a number and just not show it to the user (see
above) by setting the width in the combo to 0.

If you are even near-serious about developing database applications, invest
the time and energy to learn VBA code. If you are a "power user" wanting to
do so, I've observed that Dr. Rick Dobson's books on "Programming Microsoft
Access <versionnumber>" from Microsoft Press are useful -- that is one of
the particular audiences that he tried to address, and he succeeded in doing
so.

Larry Linson
Microsoft Access MVP

"my-wings" <my******@TAKEOUTatt.net> wrote in message
news:U6*********************@bgtnsc04-news.ops.worldnet.att.net...

"Larry Daugherty" <La********************@verizon.net> wrote in message
news:FO****************@nwrddc02.gnilink.net...
Did you follow the track to www.mvps.org/access ? If not, it's worth a peek

Yep. I actually googled the words "access lookup field evil" (without the
quotes) and it's the top entry. All the reasons not to use lookup fields
were there. But I still don't understand what to use instead.

Having a lookup table with the state codes is a great idea but you get at it
with the query for your combobox on the form rather than having it percolate
up as an artifact of a table. You have exactly the same access to your

data
and in exactly the same form.


But this is the part I don't get. How does the data get from the combo box
on the form back into your table? And what is recorded in the table? I
still have this field called "state"....how does it get any information

into it, and what kind of information is there? I understand the solution is
queries and combo boxes on forms, but I don't understand how things are
hooked together if there is no lookup field in the table.

After more carefully re-reading your post, I have a feeling that you may
have confused Lookup Fields in tables with "lookup tables".
No. I was referring to the Lookup Field you get in a table when you select
Lookup Wizard from the data types.
Lookup tables
are a good thing. They are just normal tables with some meaningful list
that is held for reference. I think you used the term Lookup Wizard

when you were actually referring to the Combobox Wizard.


Nope. Was referring to the Lookup wizard available in table design, not

the one that creates combo boxes on forms.
Lookup tables good; Lookup Fields BAD. All is well.
Or all will be well when I figure out what to use instead of lookup

fields, lol.

I appreciate your reply, but as you can see, I'm still puzzling over this.
I'm working my way through a book called Microsoft Office Access 2003 Inside Out. I'm only on Chapter 5, so maybe things will clarify themselves as I
proceed. Right now, it looks like in the places I would have put lookup
fields, the author used the relationship builder to show a connection
between the regular table and the lookup table. When I look at the tables
with data, there are no drop down lists. Just the data itself.

Excuse me a minute while I go build a quick form.....

Back with an "ah ha!". Let's see if I have this right:

1. Create tblAddresses with a "state" field.
2. Create tlkpStates with its "state" field.
3. Go to Tools/Relationships and add both tables.
4. Drag the tblAddresses "state field" to tlkpStates "state field" and
create a many-to-one relationship.
5. Create a form.
6. Use the combo box wizard to create a combo box from tlkpStates. At the
appropriate screen, say that you want to store the result in tblAddresses
"state" field.

Then, as long as you use the form to enter things, the only things in the
tblAddresses "states" field will be entries from tlkpStates. On the other
hand, if someone were to enter directly in the table, there would be no
protection that the entry exists in the tlkpStates. Which is why you can't
let people enter things directly in tables, I'll bet.

I hope I have this right finally. The above looks like what everyone has
been saying, but without working my way through the combo box wizard, I
didn't see where the "connection" was being made.

I think I'm marginally less confused now, but hopefully someone will let me know if I still don't understand this correctly.

Thanks.

Alice

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Lucas Lemmens | last post by:
Dear pythonians, I've been reading/thinking about the famous function call speedup trick where you use a function in the local context to represent a "remoter" function to speed up the 'function...
1
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a...
10
by: MJ | last post by:
How can you update a Lookup List after it is created. It is not tied to any table. I have tried adding the new data at the table level, but when I go to the Form to input, it isn't on the list. ...
1
by: jhicsupt via AccessMonster.com | last post by:
Bear with me – a long question but hopefully someone can help me. I have a survey which uses weighting to get the final score. I’m trying to find the best way to calculate the final score. I...
5
by: Kevin | last post by:
I was reading on the mvps.org site not to use the lookup wizard in the table design, but rather use a query. I'm confused by this, given that the lookup wizard basically creates a query and uses...
1
by: LurfysMa | last post by:
I am working on an electronic flashcard program. Most of the subjects are simple lists of questions and answers. Those seem to be working. Some of the "subjects" have "categories" of questions. ...
4
by: someone | last post by:
Could someone direct me to a site that would help me with the following: Have database setup and loaded. Want to create web page that will use database to do lookup of database on screen and...
11
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways. 1. A plain text field Create a text field in...
2
by: Kursat | last post by:
Hi, In my Windows applications I generally use lookup forms to show a list of values to users and these windows are generally modal. Users select any item from list, press OK button and details...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.