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
577 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
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 …

773 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