Issues creating a lookup in a table

emma313823

New member
Local time
Yesterday, 23:20
Joined
Jul 17, 2024
Messages
10
All I'm experiencing an issue when trying to creat a lookup in a table. I have one unique table called tblPrincipal - just a list of name. I want to have a lookup or a dropdown in another table to allow me to more quickly grab the correct name to reduce inaccurate entry by manually typeing. When I try to use the lookup wizard to create this I'm getting an odd message and whatever is happening is changing my field principal data type from Short Text to Number.

1721400455499.png


Emma
 
Do NOT create lookups on tables. Lookups should be used on forms for the user to use to choose options. Tables are only used by you. YOU do not need the dropdown because you do not do data entry. If you need to see the lookup value in a query, add a join to the lookup table.

You will find lots of reasons to avoid using table level lookups. Take their advice. They are more trouble than they are worth and usually end up confusing you once you move to writing code or queries because you're never looking at actual data. Anything you do that obfuscates the actual contents of a table field, will eventually cause you pain.
 
1. Do not actually do the lookup in the table. Access unfortunately provides this feature which causes lots of problems.
Do the lookups in forms using comboboxes.
2. Your tblPrincipal should have a Primary Key and normally that is an autonumber. Your table above should store that number.
the priniple table likely has fields like.
-- Principal_ID ' autonumber primary key
-- FirstName
-- LastName
-- other important fields

3. To do this in a combobox. You bind the comboox to Prinicipal storing the autonumber. Your combox however shows a name and stores an ID.
You do this by returning two or more columns of data. The first column is the Principal_ID the other is name information.
To show the name but store the ID you hide the first column the bound column.
To hide the column you set the column width to zero
example

Column Count:2
Bound Column:1
Column Widths: 0";2"
 
Thank you both for this valuable info. I appreciate the clarity as well.

Emma
 
Take a look at this video. Seems to show it well
 
All I'm experiencing an issue when trying to creat a lookup in a table. I have one unique table called tblPrincipal - just a list of name. I want to have a lookup or a dropdown in another table to allow me to more quickly grab the correct name to reduce inaccurate entry by manually typeing. When I try to use the lookup wizard to create this I'm getting an odd message and whatever is happening is changing my field principal data type from Short Text to Number.

View attachment 115235

Emma
Hi Emma
You currently have a field named "Principal" in your table named "tblIncomingCommissions", which you have originally set as a text data Type.
What you would need to do is add a field named "PricipalID" and set this as a Number DataType LongInteger.

Then on your Form which is Bound to "tblIncomingCommisions" you would create a Combobox which you would setup
to enable you to select the specific Principal from the "tblPrincipal"

When you select the specific Principal the PrincipalID would be stored in tblIncomingCommissions
 
If you construct your design as I showed you in your other thread:
1721412544156.png

then all you need to do is create your forms. Each form should be bound to its related table using a query as its Record Source.
Do you know how to do that?
 
Since this is a fairly uncomplicated project, I would suggest you use sub-forms for data input. No code is required, and new records can be added easily since the forms themselves can be connected using Master/Child fields.

Do you need help to do that?
 
Do NOT create lookups on tables. Lookups should be used on forms for the user to use to choose options. Tables are only used by you. YOU do not need the dropdown because you do not do data entry. If you need to see the lookup value in a query, add a join to the lookup table.

You will find lots of reasons to avoid using table level lookups. Take their advice. They are more trouble than they are worth and usually end up confusing you once you move to writing code or queries because you're never looking at actual data. Anything you do that obfuscates the actual contents of a table field, will eventually cause you pain.
There is a good reason why one might what to create a lookup on a Table.

For instance, let's say that Table will be referenced by many Forms. When the Field is added to a Form in design view, the Drop Down is automatically created. This saves a lot of development time.

When I am done with designing the Screens, I go back and remove the drop downs in the Tables.
 
There is a good reason why one might what to create a lookup on a Table.

For instance, let's say that Table will be referenced by many Forms. When the Field is added to a Form in design view, the Drop Down is automatically created. This saves a lot of development time.

When I am done with designing the Screens, I go back and remove the drop downs in the Tables.
I would tend to do it as I go and not use lookups in tables
 
All I'm experiencing an issue when trying to creat a lookup in a table. I have one unique table called tblPrincipal - just a list of name. I want to have a lookup or a dropdown in another table to allow me to more quickly grab the correct name to reduce inaccurate entry by manually typeing. When I try to use the lookup wizard to create this I'm getting an odd message and whatever is happening is changing my field principal data type from Short Text to Number.

View attachment 115235

Emma
Do not change the Data Type if it is already a number. Use the Long Format for the Number.

On the bottom have of the Table Designer you will see the "Lookup" Tab. See my sample snippet as a guide.

1721485931389.png
 
I would tend to do it as I go and not use lookups in tables
It is a matter of preference, but for me it can save a tremendous amount of time.

I have mostly automated my application development. I am about to move it from an Excel File to an Access Database. But I create Tables, Fields and all their associated Properties in a Table on a Sheet. I have formulas that automatically PK and Index Fields based on their Name and the Key at the end of the Field, like "_ID" for instance. It automatically populates Captions, Descriptions, etc. I can create Expression or Calculated Columns. This is useful especially if I intended to scale up to SQL Server using Computed Columns. If I want to add a Lookup Column, I can. I can also define my Relationships, as well. With a click of a button on the Sheet, the application is spun up in a matter of seconds. I like being able to create Tables and Fields in a List fashion because I can scroll up and down and make sure everything is congruent in a fraction of the time it takes me to close and open tables in design view.

I will move that into my Template Database that I used to automatically create all my Queries and base Forms so that it is in a single application.

When I distribute a Production Database Application, I purge the App of all my designing techniques, such as the Lookup Columns.

With the tools that I have developed, I have reduced the amount of time to spin up a new application by more than 65%. I realize that hurts my bottom line, but I add a fee to help cover that cost. It helps the client and I have more than covered the cost of development already.
 
Too true but when it comes to someone who is not at developer level, I think they should be advised to do it the correct way.
 
Too true but when it comes to someone who is not at developer level, I think they should be advised to do it the correct way.
I prefer not to discriminate in that way. The feature is there for a reason.

I will never tell someone not to use something, but I may provide reasons why I may not. I let them decide why or why not to use it. That is empowering.
 
For instance, let's say that Table will be referenced by many Forms. When the Field is added to a Form in design view, the Drop Down is automatically created. This saves a lot of development time.
Forms are created once each. How many forms do you create from the same table? Not usually more than a couple. However, you write a lot more code and queries. If you are creating enough forms from a single table that you think that having a form level lookup saves you work, you should probably reconsider your entire design.

Ignore the warning as you wish. It comes from not just me but also from others who know quite a bit about Access. Of course if you don't write code or update queries, you may not have run into the issues. You've been around for a long time with very few posts so either you don't feel confident in your Access skills to help others or you have no interest in helping others.
 
Last edited:
It's so easy to create a look up in a form, even if I had to do it a couple of times, it's no big deal. That said, I use to create the lookups in the tables first and then remove them after I finished the forms. I just don't find that it saves much time to bother with it anymore.
 
Forms are created once each. How many forms do you create from the same table? Not usually more than a couple. However, you write a lot more code and queries. If you are creating enough forms from a single table that you think that having a form level lookup saves you work, you should probably reconsider your entire design.

Ignore the warning as you wish. It comes from not just me but also from others who know quite a bit about Access. Of course if you don't write code or update queries, you may not have run into the issues. You've been around for a long time with very few posts so either you don't feel confident in your Access skills to help others or you have no interest in helping others.
Hi Pat. I have never been able to get table lookups to work for me very well, so I never use them, but I have a question. If you do add a table lookup field to a form as suggested above, do you still get the same Event Procedure options such as Before Update and After Update as you do by adding a combobox to a form?
 
Forms are created once each. How many forms do you create from the same table? Not usually more than a couple. However, you write a lot more code and queries. If you are creating enough forms from a single table that you think that having a form level lookup saves you work, you should probably reconsider your entire design.

Ignore the warning as you wish. It comes from not just me but also from others who know quite a bit about Access.
I always love it when someone tells me that I need to change my design techniques. I am not sure to the level or degree that you have developed, but a lot of people developing in Access have not developed to the degree that I have in my career since 1991. I have also developed in DBase, Fox Pro, Paradox, Delphi, Quickbase, Salesforce, JD Edwards on Mainframe... Access will always be my go-to as long as the customer has an internal-facing audience. I can make Access look just like an EXE Application. The Users would not know the difference.

There is not a one-to-one for Table per Form. When a Table is structured to allow many Types, as in the case of this Entity Table, I use the Table to host all Vendors or Suppliers, Customers, Employees, etc. I certainly do not use the same Form each Entity type. I may have 5 Forms, maybe more, referencing this same Table depending on the requirement.

1721490307186.png


That said, when drop the Field onto the Form, the Lookup, i.e. Combo or List box, is automatically created.

So, I want you to perform a little experiment, and do not push yourself, but do so in your normal method of developing, time yourself as to how long it takes to create a combo or list box on a Screen referencing 4 Fields for the List, defining the Column Widths etc. Now multiply that * 5, assuming you would be adding it to 5 different screens. To me that is precious development time that could have been spent doing something else.

That is just one case as an example. I am not saying any of this to brag, because I certainly have other things to do. I have literally developed ERP Applications in Access that have over 2000 Forms and Reports, each. I can hear it now.... what application would ever need 2000 Forms! Can you imagine an ERP Application for manufacturing that can handle solids, liquids, food ingredients, weights, all the factoring, Automated Inventories, BOMs, AR, AP, Work Order Management, integrating 3rd party applications like AutoCad, MasterCam, Scales, etc.? A lot of those applications were created in Modules (not to be confused with VBA Modules) for distribution. The application also performs Financial Reporting, budgeting, trend analysis, etc. The BE had been scaled from an Access BE in its earlier days individually, to SQL Server to handle over 80 different manufacturing facilities collectively, and now resides on Azure SQL DB to the best of my knowledge. I have since retired, but to the best of my knowledge it is still in use today.

I have also developed Loan Origination and Servicing Applications in Access that connect to Banks for Merchant Services and Lockboxes. The only public facing web application is a payment portal and the ability to retrieve a variety of relevant reports. I was with the company for 8 years, where it began in a spreadsheet managing over 2,000 Loans on a portfolio of $23m to over 12,000 active loans on $190m and overall serviced over 70,000 loans for a niche market in property tax liens. I also wrote all their underwriting logic for analyzing over 25 million taxable properties in Texas just so they could market to the usual 100,000 on average delinquent properties. I retired from there in 2019.

These applications are very complex where a lookup or enumerator column can be referenced many times. For that reason, I have a method to my development madness to reduce the amount of development time. I do develop a lot smaller applications now in my sunset years, but I do not change my development techniques.

My apology for the dissertation. Have a great weekend!
 
I am not sure to the level or degree that you have developed, but a lot of people developing in Access have not developed to the degree that I have in my career since 1991.
And you've been so very generous over the past 12 years with all your help to the folks who come here because they need it. You've amassed a whopping 162 posts. We will be happy to learn from you. I'll get my notepad out.
 
Last edited:
I used table lookups when I did not know any better. :)
However I understood how they work. Despite that, I would not use them anymore, but do not want to retrofit what has been completed and will unlikely ever get touched again.

All 4 fields in this table after ID have table lookups.
This was my first Access DB, hence ID as the name of the autonumber field. :)


1721496627593.png


1721496753139.png
 

Users who are viewing this thread

Back
Top Bottom