Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using values form dropdown box to set field default value

Posted on 2010-11-17
2
Medium Priority
?
871 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

926 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