Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   
 
MS Access

Continuous Form - Dependent Combo

How to have a Continuous Form but with a Dependent Combo per Record

I came across an issue recently where I needed to have a Continuous Form but with a Dependant Combo.

Access doesn't do this as a combo contains the same recordset for each record or row.

In this example we have a list of Students that have a list of Options or Choices for the Subjects they have picked.

Each Subject has a set of Grades that can be achieved. These are different for each Subject.

Subjects
SubjectType
Applied ScienceA Level
ArtBTEC
......

Grades
GradeIDGradeType
1A*A Level
2AA Level
3BA Level
4CA Level
......
10Dist+BTEC
11DistBTEC
12MeritBTEC
14PassBTEC
......

I could create a combo with ALL grades but then a user may choose a Grade for a Subject that isn't correct.

My solution is to use a Textbox control over a ComboBox that displays the value and to requery the Combo when it is selected.

First create a Query that filters the Grades given the Subject choice.

You can do this by getting the value from a Form and using it as Query Criteria. This Tip explains how.

	SELECT * FROM tblGrade WHERE Type=#
	

We need 3 controls:

  • TextBox to store the chosen Grade [Grade]
  • ComboBox to chose a Grade [cboGrade]
  • TextBox to display the chosen Grade [txtGrade]

The First TextBox can remain hidden, just have it at the back.

The ComboBox can be filled with the above Query.

The second TextBox can be use a DLOOKUP to get the Grade value.

	=Nz(DLookUp("Grade","tblGrade","GradeID=" & [Grade]),"")
	

I've stacked these to show each of them, layer these ontop of each other.

Now when the user selects the ComboBox Refresh it so the Query updates.

VBA
	Private Sub cboGrade_GotFocus()
		Me.Refresh
	End Sub
	

When a Grade has been chosen from the ComboBox set the Grade TextBox to the value of the ComboBox, then Save the Record and then set the Focus of the other TextBox so that it comes to the forefront.

	Private Sub cboGrade_AfterUpdate()
		Grade = cboGrade '.Column(1)
		Me.Dirty = False 'DoCmd.RunCommand acCmdSaveRecord
		txtGrade.SetFocus
	End Sub
	

This will now use the DLOOKUP to get value and display it. It will appear as if the combo is showing it but it isn't.

 

Alex Hedley (Avatar) By: Alex Hedley


Click here to sign up for more FREE tips

 

 

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 10/10/2024 2:08:51 AM. PLT: 0s