Solved

VB code for Data Population & Creating Cascade Combo Boxes

Posted on 2013-06-25
5
391 Views
Last Modified: 2013-07-15
Data Entry FormQueryComboBox Data PropertiesComboBox EventPropertiesI have a data entry form in ACCESS program (someone else created) and I can't find VB code that populates the first name in the first name field when last name in the last name/first name drop down/combo box is selected.

Ultimately I need  to create two drop down boxes - (1) last name only and (2) once the user selects the last name and taps over to first name combo box, it will display first names only with the last name selected in the last name combo box.

But I can't even figure out where to find VB code on the current form where the first name is automatically populated once the last name is selected.
0
Comment
Question by:sglee
  • 2
  • 2
5 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39276383
You can use the AfterUPdate event of the first combo:

Sub YourFirstCombo After_UPdate()
  Me.YourSecondCombo.RowSource = "SELECT Emp_ID, First_Name FROM Emploee WHERE Last_Name='" & Me.YourFirstCombo.Column(1) & "'"
End Sub

I'm not sure of the actual Column to reference in YourFirstCombo ... the code above refers to the 2nd combo. If you need to refer to the 3rd column, use Me.YourFirstCombo.Column(2)
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 39276399
LastNameCombo row source: Select LastName from table1
FirstNameCombo row source: Select FirstName from table1 where LastName = LastNameCombo

LastNameCombo AfterUpdate event: FirstNameCombo Requery
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 39276452
I gave the idea,  LSMConsulting included the proper quoting
0
 

Author Comment

by:sglee
ID: 39276539
Thanks for the combo box suggestions above.

Can you see where I might be able to find the VB code that populates first name into the first name field (at this point, first name field is NOT a combo box. It is just text field)
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39277526
I'm not sure what you're asking. The FirstName field could be "bound" to a control, or it could be filled through code action somewhere. The images you've given us aren't sufficient for us to tell this, and since we have no idea how the form is used it's impossible for us to say.

You could perhaps upload a copy of your database with specific instructions on how to recreate the issue. If you do this, be sure to remove any sensitive information first.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

867 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

16 Experts available now in Live!

Get 1:1 Help Now