Solved

VB code for Data Population & Creating Cascade Combo Boxes

Posted on 2013-06-25
5
395 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
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…
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.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

733 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