Link to home
Start Free TrialLog in
Avatar of bilbo-uk
bilbo-uk

asked on

MS Access 97 query - Checkboxes to new field

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
Avatar of rockiroads
rockiroads
Flag of United States of America image

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
Avatar of bilbo-uk
bilbo-uk

ASKER

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?

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
ASKER CERTIFIED SOLUTION
Avatar of bilbo-uk
bilbo-uk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial