?
Solved

Using correct syntax from Combo Box in Access Query

Posted on 2013-10-23
2
Medium Priority
?
529 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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.
Suggested Courses

765 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