?
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
Medium Priority
?
591 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 500 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
Dale Fye earned 500 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 500 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…
Suggested Courses

770 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