Solved

Using values form dropdown box to set field default value

Posted on 2010-11-17
2
852 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now