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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New results: This function@subform crashes - but why?

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
0
0
DE
For those who were following my miserable quest on why access 2002 form crashes for no obvious reason (thank you for all the tips already), I have a new theory. By removing some related code, so far I had no crashes any more. However this code is essential for me to display data in a sub form:

Function bitCompare(intByte As Byte, intBitNumber As Integer) As Boolean
If (intByte And 2 ^ intBitNumber) Then bitCompare = True Else bitCompare = False
End Function

This one takes a byte value (which is actually saved in the record as a byte integer number) and checks if a specific bit (numbered 0 to 7) is set or not set. I am doing it this way to save space (1 byte < 2 bytes * 8 checkboxes = 16 bytes).
In a continous subform I then have several checkboxes with controlsource properies &quot;=bitCompare(intByte@record, 0/1/2/3/etc...&quot;

This code works fine - it does what it is supposed to do. Except it crashes sometimes...
- Is anything wrong with this code?
- Are 150 executions of this code (= # of entries @ subform) too much for Access?

(Problem is I can not go back to true boolean values, because large amounts of data were input already; also this would increase the size of the database by factor 16 (10 MB -> 160 MB - undiscussable!))
 
I use to compare bits a lot when working in Fortran years ago. Sometimes I had a problem with overflow. I ran examples of yours (Access 2000) but couldn't get it to fail. However, you might try the following to see if you are having overflow problems.

Function bitCompare(intByte As Byte, intBitNumber As Integer) As Boolean
Dim intTest as Integer
intTest = intByte
If (intTest And 2 ^ intBitNumber) Then bitCompare = True Else bitCompare = False
End Function
 
Thanks fancy,

that buffer overflow thing feels like its going in the right direction. I tried your modification but still no luck (access 2002) :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top