yes/no in UNION

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

typical yes/no......turns to .....0/-1.....but this is in a Union....i can't
find a way to edit the format properties in the UNION....any ideas....and if
the idea is some code...please explain where to go to write in the
code....i'm not and brand newbie....more like a pretty dumb novice....thanks
 
Realistically, queries are just for data retriveal.
They are not the user interface.
Use a form in Datasheet view if you want to control the display.

If this is for export (i.e. you don't mind that the results are text and not
real true/false values) you can use the Format() function to convert the
value, e.g.:
SELECT Format([MyYesNoField], "Yes/No") AS MyExportName FROM ...

If you really, really want to set the Format property of the field in the
UNION query, you can do it programmatically using the code below like this:
Call
SetPropertyDAO(CurrentDb.QueryDefs("Query1").Fields("MyYesNoField"),
"Format", dbText, "Yes/No")


Function SetPropertyDAO(obj As Object, strPropertyName As String, intType As
Integer, varValue As Variant, Optional strErrMsg As String) As Boolean
On Error GoTo ErrHandler
'Purpose: Set a property for an object, creating if necessary.
'Arguments: obj = the object whose property should be set.
' strPropertyName = the name of the property to set.
' intType = the type of property (needed for creating)
' varValue = the value to set this property to.
' strErrMsg = string to append any error message to.

If HasProperty(obj, strPropertyName) Then
obj.Properties(strPropertyName) = varValue
Else
obj.Properties.Append obj.CreateProperty(strPropertyName, intType,
varValue)
End If
SetPropertyDAO = True

ExitHandler:
Exit Function

ErrHandler:
strErrMsg = strErrMsg & obj.Name & "." & strPropertyName & " not set to
" & varValue & ". Error " & Err.Number & " - " & Err.Description & vbCrLf
Resume ExitHandler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant

On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
 
Back
Top