473,385 Members | 1,531 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,385 software developers and data experts.

Combining two lookup fields

I am trying to combine two lookup fields into one field for display on a
form and a report. I understand the basics behind how to do this:

I set the control source for a new text box control to
=[HabitID] & [ClassID]

The problem is, this gets me a number. You see, HabitID and ClassID are both
lookup fields on the Control Source table to the form. So, if I have a field
on the form named HabitID, it would be a combobox that looks up values from
tblHabit. Thus, the user sees a list of habits but a number is actually
stored in the table. How can I get this new field set up to combine the two
fields HabitID and ClassID and convert it to its text equivalents?

Jun 19 '06 #1
1 6515
If you also have combos on this form that have the text values in their 2nd
column, you could read the values from the Column() of the combo:
=[cboHabitID].Column(1) & " " & [cboClassID].Column(1)

If you don't have those, you could use DLookup() to read the value from the
respective tables:
=DLookup("HabitName", "tblHabit", "HabitID = " & Nz([HabitID],0) & " " &
DLookup("ClassName", "tblClass", "ClassID = " & Nz([ClassID],0)

For more info on how to use DLookup(), see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Smith" <so*****@microsoft.com> wrote in message
news:2h*********************@fe07.news.easynews.co m...
I am trying to combine two lookup fields into one field for display on a
form and a report. I understand the basics behind how to do this:

I set the control source for a new text box control to
=[HabitID] & [ClassID]

The problem is, this gets me a number. You see, HabitID and ClassID are
both lookup fields on the Control Source table to the form. So, if I have
a field on the form named HabitID, it would be a combobox that looks up
values from tblHabit. Thus, the user sees a list of habits but a number is
actually stored in the table. How can I get this new field set up to
combine the two fields HabitID and ClassID and convert it to its text
equivalents?

Jun 19 '06 #2

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

Similar topics

3
by: my-wings | last post by:
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...
5
by: M.Stanley | last post by:
Hi, I'm attempting to create a query that will combine 2 columns of numbers into one. The followng comes from 1 table with 4 fields (A,B,C,D) A B RESULT 700 000 700000 700 001 ...
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...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
4
by: Omey Samaroo | last post by:
Dear Access Gurus, Can anyone provide me with some much needed assistance. I would like to combine the contents of 3 text fields into one field. Can someone provide some code or a method to do...
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: Lance Williams | last post by:
How can you programatically tell if a field in a table is a lookup field? I am looping through the fields collection and I want to see if any fields are lookup fields. Is there a property, or...
7
by: samdev | last post by:
I have set up a table with a few fields that are set to required....all work fine except the fields that are Lookup from another table. What am I forgetting to set? Thanks!!
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.