?
Solved

Access Query from Combobox to fill Form Data Not Working

Posted on 2013-12-03
3
Medium Priority
?
641 Views
Last Modified: 2013-12-04
I have a form with two combo boxes, the second combo box being filtered by the first.  When I make my selection in the second combo box (the Program field), I can not get the query to work to select the record of data to display in the form.

I make my selection, then I get an "Enter Parameter Value" message box that shows my Program selection as the parameter to enter.   If I type the Program again in the box, my data then displays.   Can anyone help me figure out what I have wrong in my query, as follows?...  

Private Sub Combo340_Change()
Me.RecordSource = "Select tblContract.* From tblContract Where [tblContract].[Program] = " & Me.Combo340.Column(0)
Me.Refresh
End Sub
0
Comment
Question by:haident
[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
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39692708
what is the RowSource of Combo340 ?

Is the field [Program] Number or Text

if text, use this
Private Sub Combo340_Change()
Me.RecordSource = "Select tblContract.* From tblContract Where [tblContract].[Program] ='" & Me.Combo340.Column(0) & "'"
'Me.Refresh

End Sub
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39692853
That generally means that a fieldname is wrong or mis-spelled in your query.

Also, you can simply filter the form like this:

If the first column in your combo is a numeric ID field (double-check the field name.  Should it be ProgramID?):

Me.Filter = "Program = " & Me.Combo340.Column(0)   
Me.FilterOn = True

Open in new window


Or if it is Text - again, double-check the field name:

Me.Filter = "Program = '" & Me.Combo340.Column(0)  & "'" 
Me.FilterOn = True

Open in new window



... and double check that you are using the correct column form your combo box.  With a default setup through the wizard, column 0 is typically a numeric ID field and column 1 is typically the associated text.
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 39693808
See my recent Access Archon article on filtering or selecting data for a form using a combo box:

http://www.helenfeddema.com/Files/accarch223.zip
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
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…

650 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