?
Solved

Using correct syntax from Combo Box in Access Query

Posted on 2013-10-23
2
Medium Priority
?
532 Views
Last Modified: 2013-10-24
I am trying to retrieve data from a access query based on a value in a combo box.  The field I am trying to pull from is a numeric field called "balance".  I have three options in my combo box that looks up from a table.  They are:

0          Paid in Full
>0       Amount Owed
>=0     All

The combo box has two columns with the first column hidden.  My query will only work when I select the "Paid in Full" option. I assume because this is numeric.  If I replace the combo box lookup criteria with any of the values above (0, >0 or >=0) the query works fine.  I am assuming that the translation for >0 and >=0 just isn't correct when pulling from a combo box.  

Is there a way to get the query to understand those values?
0
Comment
Question by:marku24
[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
2 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1200 total points
ID: 39595695
So you're referring to your combo directly in the query?

I'm not sure you can do this, but you can try this:

Forms!YourForm!YourCombo.Column(0)

You could also use a Function:

Function GetMyValue() As Integer
  GetMyValue = Forms("YourForm").YourCombo.Column(0)
End Function

Then use the function name "GetMyValue" instead of directly referring to the combo in your query.

However, the BEST way to do this is ... don't refer directly to forms in your queries! While you certainly can do it, inevitably it leads to troubles down the road (like this one). A query should be used to retrieve and manipulate data, and it really should not be tightly bound to a specific object. In your specific case, if you have need of another identical query that refers to a different Form, you'd end up with another query. I've seen databases with dozens of identical queries used for the same thing, each referring to different Forms. Those are nightmares to fix when something needs to be changed ...
0
 

Author Closing Comment

by:marku24
ID: 39597328
Made adjustment based on suggestions.  Couldn't reference a numeric field so changed it to text and it worked great.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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 …
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

649 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