Solved

Getting DropDown to Work

Posted on 2010-11-11
9
280 Views
Last Modified: 2012-05-10
I have made dozens of these dropdowns on forms. For some reason I can't get this one to work.
Basically, I want to choose the name from the dropdown list, and have it populate the form DropDown.mdb
0
Comment
Question by:4charity
  • 4
  • 4
9 Comments
 
LVL 7

Expert Comment

by:shaydie
ID: 34113838
Your dropdown is an unbound control and there are no events.. If you just set the combo box control to InsuredName it will select the correct record.
DropDown.mdb
0
 

Author Comment

by:4charity
ID: 34113862
I changed the control source on the combo box to InsuredName. It chanes the insured name, but not the rest of the controls.
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 34114089
Based on the limited textboxes on the form change the rowsource for the listbox to

SELECT i.InsuredName, d.InsuredPrimaryContact, d.InsuredEmail, d.InsuredPhone FROM tblInsuredName as i, tblInsureDetails as d WHERE i.InsuredID = d.InsuredID

So the query for the combo here returns the name and associated contact - run this query individually so you can see what it produces.

Ensure number of columns (property is ColumnCount) is set to 4 in the combo

then on the afterupdate you reference the value to the textboxes like this

Private Sub cboInsuredName_AfterUpdate()
    Me.InsuredName = cboInsuredName.Column(0)
    Me.InsuredPrimaryContact = cboInsuredName.Column(1)
    Me.InsuredEmail = cboInsuredName.Column(2)
    Me.InsuredPhone = cboInsuredName.Column(3)
End Sub


This will then take the values from the combo and populate the form
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:4charity
ID: 34114121
@rockiroads:

Could I also add a filter here, instead? If so, what would be the best way to do that?
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 500 total points
ID: 34114130
What would be better though if you wanted to add more columns and maybe use the id for other things is like this

The rowsource for the combo should be

SELECT InsuredID, InsuredName FROM tblInsuredName

Column count is 2, but column width is something like this  "0;2.54". Reason for this is we hide the first column, no need to show the id.

Then on the afterupdate event you have the id so you can read the table(s) and do whatever

Private Sub cboInsuredName_AfterUpdate()
    dim rs as dao.recordset

    set rs=currentdb.openrecordset("select * from tblInsureDetails where insuredid = " & cboInsuredName.value)
   
    Me.InsuredPrimaryContact = rs!InsuredPrimaryContact
    Me.InsuredEmail = rs!InsuredEmail
    Me.InsuredPhone = rs!InsuredPhone

    'etc

    rs.close
    set rs=nothing
End Sub
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34114178
>> Could I also add a filter here, instead? If so, what would be the best way to do that?

I am assuming filtering the combo? Well yes you can. What do you want to filter on? Take for example the name. You could introduce a textbox and a button over it
eg

txtFilter and cmdFilter

then on the click update the rowsource
eg

private sub cmdFilter_Click
    if trim(nz(Me.txtFilter,"")) = "" then
        msgbox "It helps if you enter something"
    else
        cboInsuredName.rowsource = "SELECT .... FROM ... WHERE InsuredName LIKE '*" & Me.txtFilter & "*'"
    end if
end sub


I left the query above like that as I do not know which approach you would like to take but essentially its the WHERE part

if the combo doesnt refesh add this after setting the rowsource

cboInsuredName.Requery


0
 

Author Comment

by:4charity
ID: 34114511
OK, not to overthink this, I looked back at my past posts, and came up with this one simple line of code:

Me.Filter = "[InsuredID]= " & Me.cboInsuredName
0
 

Author Closing Comment

by:4charity
ID: 34114517
OK, not to overthink this, I looked back at my past posts, and came up with this one simple line of code:

Me.Filter = "[InsuredID]= " & Me.cboInsuredName
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34116379
Ah, I thought it was the combo you wanted to filter and not the form.  Remember to use FilterOn to toggle between filtering and not
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

860 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