Solved

Access 2007 how (or is it possible) to have a query expression return a checkbox to display the value?

Posted on 2010-11-30
5
585 Views
Last Modified: 2012-05-10
I have a table in which is indicated whether one service is marketed with Other Service A or Other Service B. Answer is one of two chosen from a drop down menu so the data is in text form.

I have 2 fields in a query with expressions that successfully return a true/false or yes/no (have tried both to no avail) in an attempt to convert the data Other Service A or Other Service B to T/F or Y/N which is displayed on a form as two check boxes. The problem is that they will DISPLAY as check marks, but I can't change it in the form like I can a regular check box.

Is there a way around this?
0
Comment
Question by:Laura Sheldon
[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
5 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 34241374
Is the column a Text column or a Numeric column? Checkboxes work with Numeric datatypes (preferably Boolean). If the field you're working with is a Text field, you'll have to change the design to manage this.

0
 
LVL 48

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 125 total points
ID: 34241903
I'm confused.  Do you mean that you have this field setup in tabledesign with a lookup, so you can select either "Other Service A" or "Other Service B" from the dropdown in table view?  If so, why aren't you doing the same thing in your form?  Why use checkboxes instead of a combo box?

If you really want to use checkboxes, you are going to have to make them unbound, and add code to them to change the value as appropriate.  Get rid of the expression in your query and just use the original field.

Then, in the forms Current event, use the expression you had in your query to determine what the value of the checkbox should be, something like:

Private Sub Form_Current

    me.chk_ServiceA.Value = iif(me.[SomeFieldName] = "Other Service A", True, False)
    me.chk_ServiceB.Value = iif(me.[SomeFieldName] = "Other Service B", True, False)

End Sub

Then, use the Click event of the checkbox, to set the value of the field, something like:

Private sub chk_ServiceA_Click

    me.[SomeFieldName] = iif(me.chk_ServiceA, "Other Service A", "")

End Sub

But with this technique, you will also have to add some code that would uncheck chk_OtherServiceB when chk_OtherServiceA is clicked, since it cannot be both at the same time.

A better technique would be to use an unbound option group, with either checkboxes or radio buttons.  With this technique, you would use the Form_Current event to set or the value of the option group based on the value in your field.  Then use the option groups click event to set the value of the form based on the selection.

0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 125 total points
ID: 34242039
Try this: I am using table t (f1 As Text)
f1
Other Service A
Other Service B
Other Service A
Other Service B
Other Service A

SELECT t.f1, [f1]="Other Service A" AS yn
FROM t;
f1                     yn
Other Service A      -1
Other Service B      0
Other Service A      -1
Other Service B      0
Other Service A      -1

0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 125 total points
ID: 34242997
Alternatively, remove the checkbox and replace it with a textbox bound to the same field, and make the format Yes/No.
0
 

Author Closing Comment

by:Laura Sheldon
ID: 34250663
All great input! Thanks for the help!
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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