Solved

Using correct syntax from Combo Box in Access Query

Posted on 2013-10-23
2
525 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
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

839 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