Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access 97 query - Checkboxes to new field

Posted on 2009-05-15
4
Medium Priority
?
381 Views
Last Modified: 2013-11-28
Hello gurus,

We have an Access Database which we are trying to port over to an Act Database.  Within the Access database are a number of checkboxes for example Type of Customer.  What I would like to do is have a new field called CustomerType which has the name of the Customer Type if it has a checkbox.  

To illustrate - let's say you have Tinker, Tailor, Soldier, Spy and one of those is ticked.  If Tinker is selected then update that record with the new field ID and have that say Tinker.

I guess it can be done with a case statement but I am not sure the syntax

In Psudocode something like

if Tinker = Yes then CustomerType=Tinker
If Tailor = Yes then CustomerType=Tailor
..
..
Else if Blank then CustomerType = Blank

Thanks in advance for any help / tips /websites to check out

Bilbo-UK
0
Comment
Question by:bilbo-uk
[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
  • 2
4 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24397046
How about using IIF?

IIF(Tinker=true,"Tinker", IIF(Tailor=true,"Tailor", "") ) AS CustomerType

Syntax is

IIF(condition,value if true,value if false)

Now within each value, you can embed another IIF as you can see from my example above.

From the example, it reads

if tinker = true then
    customer type = tinker
else
    if tailor = true then
        customer type = tailor
    else
        customer type = blank
    end if
end if
0
 

Author Comment

by:bilbo-uk
ID: 24397183
Hi there rockiroads,

Would require sql commands within the VBA would it not?  Any ideas what those would be?

I'm a little confused as you put IIF at the top but in your example are using IF so basically a nested if construct - should it be if or iif?

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24397317
I dont know how you are doing your export. Are you using SQL or straight VBA?
Given sql, you can select all the fields you want, then run it, exporting results into a csv file. I am not familiar with act database but there may be a import process that allows csv imports.

Correct syntax is IIF in SQL
In VBA it is IF
0
 

Accepted Solution

by:
bilbo-uk earned 0 total points
ID: 24848675
We ended up doing it a long winded way but done now

Thanks

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

722 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