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
581 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 84

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 47

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

726 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