Solved

Using correct syntax from Combo Box in Access Query

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
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 …

777 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