Solved

Using values form dropdown box to set field default value

Posted on 2010-11-17
2
855 Views
Last Modified: 2013-11-28
Hello Experts!

How can I assign a field's default value from a selected value in dropdown box?

Background:

tblStudent table (lists all students and attributes with a school field call tblSchool). I could set the default value of this field to, say "Pacific High School", in design view but more that one school will use this database. I have another table with settings, tblSettings that I keep the school's name. Users can set the name when they first login to the application by selecting  their school  name in a drop down box. Their selection is written to the tblSettings table, tblSettings_School field.

What I would like to do is when a new record is written the default value for the School field in the tblStudent table will default to the value listed in tblSettings, tblSettings_School field.

I tried setting the default value in design to [tblSettings].[tblSettings_School] but that didn't work.

Any help you can provide would be great

Thanks in advance for this?
0
Comment
Question by:shogun5
2 Comments
 
LVL 10

Accepted Solution

by:
t_hungate earned 500 total points
ID: 34161346
You can create a hidden txt box on your form with a control source of  [tblSettings].[tblSettings_School], name it txtDefaultSchool. Then on your form, just set the school field to match the txtDefaultSchool, unless changed by the user.

TLH
0
 

Author Closing Comment

by:shogun5
ID: 34161505
Okay, that will work too. I had to use =Nz(DLookUp("tblSettings_School","tblSettings"),0) as the control source for txtDefaultSchool and then assigned this value to txtSchool field on the Form Load event.

Thanks again!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question