Solved

VB code for Data Population & Creating Cascade Combo Boxes

Posted on 2013-06-25
5
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 85

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 85

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses
Course of the Month5 days, 9 hours left to enroll

627 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