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

Using Lookups and Display in Forms

I'm back in the Access development mode and seem to have forgotten how to do
2 things that should be simple. I have a database with a table of contacts,
companies and activities. The idea is that I'll put in a list of companies,
a bunch of contacts that work at each company, and an activities form that
allows me to input every activity I do for each contact.

The activities table includes a lookup field (also named contactID) for
contactID field in the contact table so that each activity is assigned to
only one contact by selecting the contact's contactID. In the contacts table
I have done the same with the companyID so that each contact is assigned a
company by using the companyID. The lookup allows me to see the contact name
in the first example and the company name in the second example so that
selection is easy. Here's what I wanted to do in the activities form:

1) I have a lookup table for the contactID which looks up the contact's name
in the contact table so that "firstname, middlename, lastname" appears in
the dropdown insead of just the contactID number. Unfortunately 2 things
occur: (a) I see the firstname, middlename, lastname fields but I want them
sorted by the lastname field -- it sorts by firstname; (b) when I finish
using the dropdown, all I see is the firstname field and the other two
disappear. I'd like to have all 3 fields appear.

2) I'd like to have a field which merely displays the companyname field from
the company table on this form. Since I have selected a contactID, I have a
companyID lookup in the contact table. I'm not sure how to set up this query
and a field that shows the results of the query in the form. Obviously this
does not have to be stored because it already has been stored and it is used
just for dispay purposes only...

Thanks all so much in advance...

Marc
Nov 12 '05 #1
2 4416
First off, lookups are AWFUL...
use a combobox, columncount = 2. widths 0;1 rowsource: "SELECT
Firstname & " " & MiddleName & " " & LastName FROM tblContacts ORDER
BY LastName;"...

Or better... "SELECT LastName & ', '& FirstName & ' '& MiddleName As
CustName
FROM Contacts ORDER BY LastName, FirstName, MiddleName;"


2) I'd like to have a field which merely displays the companyname field from
the company table on this form. Since I have selected a contactID, I have a
companyID lookup in the contact table. I'm not sure how to set up this query
and a field that shows the results of the query in the form. Obviously this
does not have to be stored because it already has been stored and it is used
just for dispay purposes only...


if you have this in a combobox, you could include the company name in
the combobox's rowsource:

"SELECT ContactID, ContactName, Company.."
then have 3 columns, with column(0) and Column(2) having zero width.
Then you could set your company textbox's rowsource =
cboContact.Column(2) and it would show up...
Nov 12 '05 #2
> 1) I have a lookup table for the contactID which looks up the contact's
name
in the contact table so that "firstname, middlename, lastname" appears in
the dropdown insead of just the contactID number. Unfortunately 2 things
occur: (a) I see the firstname, middlename, lastname fields but I want them sorted by the lastname field -- it sorts by firstname; (b) when I finish
using the dropdown, all I see is the firstname field and the other two
disappear. I'd like to have all 3 fields appear.
Since the combo box is based on a query, then simply bring up the combo box,
click on the sql data source, and set the sort for last name to be
descending. You should probably thus make the combo box have CntactId,
LastName, middle, First. (Make whatever field you want to search by the 2nd
field to the contact id). Once the user selects the name, then contactId is
set. You can either display Middle, first etc by placing additional text
boxes on the screen, and using dlookup's as the source for each text box.
However, that is a bit messy, so you can consider basing the form on a sql
that joins in those additonal fields. Even more cool is to consider using a
sub-form. I explain how to do this at:
http://www.attcanada.net/%7ekallal.m...000000005.html
2) I'd like to have a field which merely displays the companyname field from the company table on this form. Since I have selected a contactID, I have a companyID lookup in the contact table. I'm not sure how to set up this query and a field that shows the results of the query in the form.


Yes, this would be double lookup. So, yea, I would use my sub-form idea, and
build a query that displays the contactId, Contact Name, and Contact
Company. You then base the sub-form on this query and you thus get to
display all the contact info, and you ONLY need to supply the contactId in
you main form to display all of this stuff! (use the link master/child in
the sub-form based on contactId).

--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
No************@msn.com
http://www.attcanada.net/~kallal.msn

Nov 12 '05 #3

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

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
3
by: Pete | last post by:
I'm currently doing a database that uses comboboxes to look up records in other tables, whether they be lookup tables or otherwise. When a user needs to add an item to one of these tables, the...
1
by: c.verma | last post by:
I am not able to hide a href element using javascript. Here is my code written on aspx page. On the click of "OK" button, I want to hide href element. But I am getting message: Object required....
4
by: Regnab | last post by:
I've got a form - "frmLookup" (with a subform) that works very happily on its own. The form has a list box, which when updated requeries the subform to display the appropriate results. The...
2
by: King Ron | last post by:
Ola all. In responding to a recent post requesting help with a search issue, I recommended using a combo box lookup in the table design. "paii, Ron" (no relation) posted this reply: " There are...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
0
by: David | last post by:
Hi Vlasta. I had a look at your original mail. I think your simpler (than XML) format is a good idea for now. At a later stage you could change it to something like this: <CUSTOM_TAG KC=12...
6
by: KEV999 | last post by:
I have a table ADDRESSPOINTS with fields ADDRESS, X and Y. This contains thousands of existing records of addresses and their associated X and Y mapping coordinates. I have a table INCIDENTRECORDS...
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...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.