Solved

Access Query from Combobox to fill Form Data Not Working

Posted on 2013-12-03
3
574 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
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle Pivot Question 8 45
Unable to save view in SSMS 21 59
email about the whoisactive result 7 23
Join multiple pivot queries 2 5
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

910 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

23 Experts available now in Live!

Get 1:1 Help Now