Solved

Access Query from Combobox to fill Form Data Not Working

Posted on 2013-12-03
3
563 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
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…
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 …

763 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

13 Experts available now in Live!

Get 1:1 Help Now