-1 True Value

C

Cynthia

How do you change a -1 true value to a positive 1 so it shows up as just 1 on
the corresponding table?
 
D

Dirk Goldgar

Cynthia said:
How do you change a -1 true value to a positive 1 so it shows up as just 1
on
the corresponding table?


You'd need to use an integer or other numeric field in the table design,
rather than a Yes/No field, and you'd need either use some other control
than a check box on the form, or else use code in the form's BeforeUpdate
event to change the value from -1 to 1 before saving the record.

Or you could leave the table and form as they are, and use a query to
convert the -1 to 1 whenever you need to report, export, or sum it.
 
C

Cynthia

Thanks. It does make more sense to leave it and just run queries and convert
it. How do I convert it?
 
D

Dirk Goldgar

Cynthia said:
Thanks. It does make more sense to leave it and just run queries and
convert
it. How do I convert it?


The details will depend on exactly what you want to do with the information.
But for example, you could have a query with SQL like this:


SELECT
ID,
SomeOtherField,
IIf(YesNoField<>0, 1, 0) As ConvertedYesNoField
FROM YourTable;

Does that make sense to you?
 
L

Linq Adams via AccessMonster.com

You don't really need a query to do this, just use the Abs() function
whenever you're dealing with it.

Abs(YourField)
Thanks. It does make more sense to leave it and just run queries and convert
it. How do I convert it?
[quoted text clipped - 7 lines]
Or you could leave the table and form as they are, and use a query to
convert the -1 to 1 whenever you need to report, export, or sum it.
 
D

Dirk Goldgar

Linq Adams via AccessMonster.com said:
You don't really need a query to do this, just use the Abs() function
whenever you're dealing with it.

Abs(YourField)


Two points, Linq:

1. Thinking about the circumstances that may be prompting Cynthia's
question, I imagine that most of the time basing *whatever* it is on a query
that does the conversion would be the simplest solution, and would involve
no VBA code.

2. If you were recommending calling the Abs() function from the query, I'd
suggest that's not a good idea, as it would force a call to the expression
service to resolve the VBA function. Using IIf() in the query won't do
that, as it's built into Jet SQL. I could be wrong about the Abs() function
not being built in, but I don't think so.
 
Top