473,398 Members | 2,088 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,398 software developers and data experts.

can link one drop-down list to another?

Is it possible to link one drop-down box to another? For example, if a
name is chosen from a drop-down list, can another drop-down list then
automatically display the person's office as a result of the choice
made in the first drop-down list? If so, how can that be done? I am
working with 'Teach Yourself Microsoft Access' and I didn't see it
discussed in that book (if it's even possible to do). Or would I just
have to create linked tables in the database layout instead?

Also, is there a way to create a 'last updated' field automatically
populated by the date at which a record was last updated?

Finally, how do I specify in which database field a value for a
checkbox should be stored?

Thanks in advance for any help on these issues!

Nov 13 '05 #1
2 9429
On 19 May 2005 13:12:32 -0700, km*******@hotmail.com wrote:
Is it possible to link one drop-down box to another? For example, if a
name is chosen from a drop-down list, can another drop-down list then
automatically display the person's office as a result of the choice
made in the first drop-down list? If so, how can that be done? I am
working with 'Teach Yourself Microsoft Access' and I didn't see it
discussed in that book (if it's even possible to do). Or would I just
have to create linked tables in the database layout instead?

Also, is there a way to create a 'last updated' field automatically
populated by the date at which a record was last updated?

Finally, how do I specify in which database field a value for a
checkbox should be stored?

Thanks in advance for any help on these issues!


1) The person can have more than 1 office?
Leave the Rowsource of the second combo box blank.
Code the first Combo Box AfterUpdate event:
ComboTwo.Rowsource = "Select [FieldName] From TableName Where
[NameField] = '" & Me!ComboName "';"

Each person has only one office?
Instead of the second combo box, use an unbound text control.
Include the office as a 2nd column in the first combo box.
then code the combo AfterUpdate event:
TextControlName = Me!ComboName.Column(1)
where the column number is the number of the column that displays the
office. The Column number is zero based, so Column(1) is the 2nd
column.

2) Add a DateTime datatype field to your table
Name it [LastUpdated].

If the table is the form's recordsource, add that field to the form
from the Field List tool button.
If a query is the form's record source, add the field to the query
first, then add it to the form from the form's Field List tool button.

Code the Form's BeforeUpdate event:
If Me.Dirty = True then
Me![LastUpdated] = Now
End If

3) Add a Check box field to the table.
If the table is the form's recordsource, add the Check Box to the Form
from the form's Field List tool button.
If a query is the form's record source, add the field to the query
first, then add it to the form from the form's Field List tool button.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
km*******@hotmail.com wrote:
Is it possible to link one drop-down box to another? For example, if a
name is chosen from a drop-down list, can another drop-down list then
automatically display the person's office as a result of the choice
made in the first drop-down list? If so, how can that be done? I am
working with 'Teach Yourself Microsoft Access' and I didn't see it
discussed in that book (if it's even possible to do). Or would I just
have to create linked tables in the database layout instead?


A simple example.

Given two tables:

TBL_PERSONNEL
PER_PK PER_FIRST_NAME PER_LAST_NAME
1 Joe Blow
2 Sally Silly
3 DP Gumby

TBL_OFFICE_ASSIGNMENT
OFF_PK OFF_PER_FK OFF_NUMBER
1 3 A-1000
2 3 A-2201
3 3 S-3456
4 1 A-2013
5 2 J-2341
6 2 B-1204A

In reality, you'd probably have a many to many relationship here with
three tables with office details listed once per office with one office
per record in a table of offices. The TBL_OFFFICE_ASSIGNMENT would have
a PK reference instead of the office number.

Anyway, make your first combo box based on the tbl_personnel table. Use
the builder to construct a row source (combo box properties window,
beside the "row source" property) that brings in the PER_PK and maybe
the combined name, PER_LAST_NAME & ", " & PER_FIRST_NAME. Do this by
constructing query when in the builder (it looks like a query design
window anyway) and bring down PER_PK as the first field and then make a
calculated field like this in the field cell:

Worker Name: PER_LAST_NAME & ", " & PER_FIRST_NAME

Close the query builder and say yes you want to make this the row source.

In the combo box properties window, go to format and indicate:

Column Count: 2 (this will be for the per_pk and worker name field)

Column Widths: 0; 2"

The 0 makes the first column (PER_PK) hidden - the user only sees the
work name.

So, you have PER_PK (which is hidden) and then the name.

Go to the "data" tab and find the "Bound column" property. Make sure it
is 1 (by default). It is the bound column that represents the value of
this combo box when a selection is made. In this case it will be
whatever the value of PER_PK is. For instance, if you choose Silly,
Sally, the value of the combo box will be 2.

Go to the name property of the properties window (click on the "Other"
tab) and give this combo box a name, say, cboName.

Now you're done the first combo box.

Next, create a second combo box. Use the builder to create a row source
(as described above). Use the table TBL_OFFICE_ASSIGNMENT.

Bring down OFF_NUMBER into the query design. Next bring down
OFF_PER_FK. this latter field is the "look up number" for the personnel
occupying the office.

Now, in the "show" check box beneath the OFF_PER_FK field, turn the
check mark off - you don't want anyone seeing this field, you just want
to show the office numbers the person selected in the first combo box.

Next, go to the criteria field immediately below the OFF_PER_FK field
and type in:

[Forms]![FrmYourFormName]![cboName]

This tells the row source of this second combo box to only show values
for the name selected in the combo box, cboName.

Name the second combo box cboOffices

You might think you're done, but there is one thing. Each time you make
a selection in the name combo box, cboName, you have to tell Access to
reevaluate what is showing in the second combo box. Some people do this
in the after-Update event of the first combo box, I prefer to do it in
the On Got Focus event of the second combo box.

In the properties window of the second combo box, cboOffices, click on
the "Event" tab. Find the "On Got Focus" event and click the builder
and choose code builder.

In the VBA screen, under "Private Sub cboOffices_GotFocus()" (Access
writes this for you), type in:

me.cboOffices.requery

This will tell the cboOffices combo box to reevaluate itself each time
you click on it.

Now you're done.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #3

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

Similar topics

2
by: Peter Shankey | last post by:
Assuming I have a db link that an application uses once in a great while. How can it be coded so that the link is close when not in use and only openned when it is needed? Thanks
9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
8
by: WindAndWaves | last post by:
Hi everyone, Has anyone got any experience with drop and drag in Access? I would like to make a calendar style form where my users can drop and drag appointments.... I am using Access 2003...
4
by: kemal asad | last post by:
how can i create a vb application where i can drag and drop ( with a move caracteristic) email from outlook, into my application( email viewer). thanks, any help is welcome, samples a great way of...
10
by: Geoff Jones | last post by:
Hi I'm trying to drop a table by using: Dim cmd As New OleDbCommand("DROP TABLE IF EXISTS books", myconnection) cmd.ExecuteNonQuery() but I get a syntax error: "Syntax error in DROP TABLE...
1
by: Just Me | last post by:
I noticed I could drag a filename from windowsexplorer onto a richtextbox and drop it as a Link and the result is a link on the box that open the file if I click it. Is that the whole story. ...
1
by: Staal | last post by:
My C# application supports drag and drop of files, folders, shortcuts and links from other applications into mine. This all works pretty nicely, except that I am trying to get a little more...
5
by: empiresolutions | last post by:
Hello Fellow Developers, I am using the awesome drag and drop script found at http://script.aculo.us/. I have also added a modification that interacts to a db for reordering upon release of a...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
3
by: cold80 | last post by:
Hi guys, maybe it's a silly question, but I'm quite stuck with it... I've tried to implement a drag and drop operation from inside my c# program. What I would like to do is allow to copy a link to...
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: 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...
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,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.