Solved

Getting DropDown to Work

Posted on 2010-11-11
9
283 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
[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
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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