Solved

VB code for Data Population & Creating Cascade Combo Boxes

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 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

20 Experts available now in Live!

Get 1:1 Help Now