AOB
Registered User.
- Local time
- Today, 15:59
- Joined
- Sep 26, 2012
- Messages
- 615
Hi there,
I have a query which returns, among other things, a number of boolean fields. In some cases, there will be a genuine True or False value in each of these fields; in others, it can and should be Null (e.g. as a result of a 'failed' LEFT JOIN of some description, where there is no associated record in the joined table which fulfills the criteria)
So something like this :
However, I will be writing the result of the query to a text file and here's the problem. I want to show a numeric value for a genuine True / False (i.e. -1 and 0 respectively using the standard boolean conversions in Access) and a blank for any Null values.
So I tried this :
However, currently when I look at the exported recordset in Notepad, I am getting 0's for both False and Null values (and -1 for True)
Any suggestions for how I can adapt my query to keep Nulls...null? And convert the genuinely present boolean values to integer form?
Only thing I can think of is to use (untested) :
But there's a number of boolean fields in there, all requiring the same treatment. Is there a quicker / more efficient method?
Thanks!
Al
I have a query which returns, among other things, a number of boolean fields. In some cases, there will be a genuine True or False value in each of these fields; in others, it can and should be Null (e.g. as a result of a 'failed' LEFT JOIN of some description, where there is no associated record in the joined table which fulfills the criteria)
So something like this :
Code:
SELECT [tblTable2].[fldBooleanField]....
FROM [tblTable1]
LEFT JOIN [tblTable2]
ON [tblTable1].[SomeID] = [tblTable2].[SomeID]
However, I will be writing the result of the query to a text file and here's the problem. I want to show a numeric value for a genuine True / False (i.e. -1 and 0 respectively using the standard boolean conversions in Access) and a blank for any Null values.
So I tried this :
Code:
SELECT [COLOR=red]CInt([/COLOR][tblTable2].[fldBooleanField][COLOR=red]) AS fldBooleanField[/COLOR]....
FROM [tblTable1]
LEFT JOIN [tblTable2]
ON [tblTable1].[SomeID] = [tblTable2].[SomeID]
However, currently when I look at the exported recordset in Notepad, I am getting 0's for both False and Null values (and -1 for True)
Any suggestions for how I can adapt my query to keep Nulls...null? And convert the genuinely present boolean values to integer form?
Only thing I can think of is to use (untested) :
Code:
IIf([tblTable2].[fldBooleanField] Is Null, Null, [COLOR=black]CInt([[/COLOR]tblTable2].[fldBooleanField[COLOR=black]]))[/COLOR]
But there's a number of boolean fields in there, all requiring the same treatment. Is there a quicker / more efficient method?
Thanks!
Al