Solved

Access Query from Combobox to fill Form Data Not Working

Posted on 2013-12-03
3
615 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

696 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