?
Solved

Access Query from Combobox to fill Form Data Not Working

Posted on 2013-12-03
3
Medium Priority
?
627 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

741 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