Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying binary data in datasheet

Status
Not open for further replies.

lizray

Programmer
May 14, 2008
126
AU
I have a datasheet with many columns. One column named "numbers" has a data source as a field of a table, another column called "binary version" displays this in binary by calling a routine to convert. When I change the value in "numbers", I want the "binary version" to change. At present I have the Data source for the "binary version" column as =convert() and this convert function should return the binary string representing the number. I have tried binaryversion.requery as the exit event of "numbers" and it works, but repaints the entire coulumn (all records). How do i change this to update only the current record, and not affect the entire column ??
 
I have tried leaving the "binaryVersion" control without a record source and setting the "on exit" event of the numbers control to BinaryVersion = convert(). This works, but assigns the same converted number to all columns, rather than the single record involved.
 
Please post your Convert function code.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
‘strTagBits is a public String Variable, bytTag is a Public Byte Variable
bytTag = Forms!Numbers
If bytTag And 128 Then
strTagBits = "1"
Else
strTagBits = "0"
End If
If bytTag And 64 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 32 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 16 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 8 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 4 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 2 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 1 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
‘ BinaryConversion is the Control
BinaryConversion = strTagBits
 
Sorry. I had not copied the complete function.
'strTagBits is a public String Variable, bytTag is a Public Byte Variable
This funcrion is the control source for the “BinaryCoversion” control

Public Function Convert() As String
bytTag = Forms!results!Numbers
If bytTag And 128 Then
strTagBits = "1"
Else
strTagBits = "0"
End If
If bytTag And 64 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 32 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 16 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 8 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 4 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 2 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
If bytTag And 1 Then
strTagBits = strTagBits & "1"
Else
strTagBits = strTagBits & "0"
End If
Convert = strTagBits
End Function
 
but assigns the same converted number to all columns
This is standard behaviour for an unbound control of a continuous form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here's another cleaner version...
Code:
Public Function Convert(iValue As Integer) As String
    Const BASE = 2
    Dim iVal As Integer
    iVal = iValue
    Do
        Convert = iVal Mod BASE & Convert
        iVal = Int(iVal / BASE)
    Loop While iVal > 1
    Convert = iVal Mod BASE & Convert
End Function

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks PHV and Skip..it is a tidier soln. I still have the problem that when I use binaryversion.requery as the exit event of "numbers" (=convert() is the Data source of the BinaryVersion control), it works, but repaints a large part of the BinaryVersion column, which is slow and clumsy looking. Any ideas on this ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top