The declaration of tmpFormAccess is Long as listed below and the IsBitSet function is also below.
When calling the function the values are: intBitIndex = 12 and lngValue = 2147483647
this user has full access to all controls for editing values.
Dim tmpFormAccess As Long
Public Function IsBitSet(intBitIndex As Integer, lngValue As Long) As Boolean
'This function will test to see if the bit specified by intBitIndex is HIGH (1)
'for the passed lngValue. intBitIndex is ZERO based from the right to the left.
'Note that bit 31
'for a Long data type has a value of -2147483648, however, 2^31 is 2147483648
'which if not negated will raise an overflow error for this function.
'
'intBitIndex: ZERO based bit index of a binary value with bit ZERO being on the
' far right.
' Bit Positions for an 8 bit Value -> 7 6 5 4 3 2 1 0
'
'lngValue: A long integer passed to the function.
'
'Example usage:
'Decimal 12 -> Binary 1100
'--------------------------
'IsBitSet(12,0) -> False
'IsBitSet(12,1) -> False
'IsBitSet(12,2) -> True
'IsBitSet(12,3) -> True
Dim lngBitValue As Long 'The numeric value of the bit being analyzed
If intBitIndex = 31 Then
lngBitValue = -(2 ^ intBitIndex)
Else
lngBitValue = 2 ^ intBitIndex
End If
IsBitSet = (lngBitValue = (lngBitValue And lngValue))
''Alternative
''IsBitSet = (((curValue \ lngBitValue) Mod 2) = 1)
End Function
I will be trying a couple of other debug methods this morning. Thanks for the reply.
Rod
---In MS_Access_Professionals@yahoogroups.com, <graham@...> wrote :
Hi Rod
Could you please post the code for your IsBitSet function? Also, what datatype is tmpFormAccess?
All the best,
Graham
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Thursday, 7 August 2014 15:51
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] having issue with checkbox
Trying to set the enabled and locked properties based on a test of a controls tabindex. This is being used to define user access.
ctlbit = ctl.TabIndex
ctl.Enabled = (IsBitSet(ctlbit, tmpFormAccess))
ctl.Locked = Not (IsBitSet(ctlbit, tmpFormAccess))
I test the bit of a number based on the tabindex of the control. I get an error of "Type Mismatch" The IsBitSet function returns TRUE or FALSE. The issue appears to be only associated with one control which is a checkbox ( two others appear to be working properly).
ctl is an control
Not sure what the issue is, am going to try deleting control and re-creating it. Any other ideas.
Using Access 2010 on Windows 7 and 8.1
Rod
Posted by: desertscroller@cox.net
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar