Solved

Using correct syntax from Combo Box in Access Query

Posted on 2013-10-23
2
522 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
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 300 total points
Comment Utility
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
Comment Utility
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 improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

771 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

14 Experts available now in Live!

Get 1:1 Help Now