Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Access
Microsoft Access ADP SQL Server
Checkbox crash
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="ESquared, post: 6972368, member: 20095"] [b]Possible workaround I discovered[/b] Regarding checkboxes or other controls bound to a SQL Server bit column in an Access ADP causing an immediate crash of Access when clicking on them: In my testing, the crash always happened after the form's BeforeUpdate event, but before the control's BeforeUpdate event. If two Form_BeforeUpdate events happen, it will occur after either of them (such as if you cancel the first one). (Access for some reason sometimes (always?) fires two Form_BeforeUpdate events. And it also (sometimes?) does some weird things with autonumber primary key fields in the meantime. A coworker tells me that during the first one, records have sequential primary key values starting with 1, and during the second one, they again have their correct server-side values.) Surprisingly, cancelling just these events seems to allow the application to not only avoid crashing but also to work normally as a user would expect. Since the control's GotFocus event fires before the form's BeforeUpdate event, we can use it to tell us when to cancel those updates: [CODE] Private gfPreventUpdate as Boolean Private Sub Checkbox1_GotFocus gfPreventUpdate = True End Sub Private Sub Form_BeforeUpdate(Cancel As Integer) Cancel = gfPreventUpdate End Sub Private Sub Checkbox1_BeforeUpdate(Cancel As Integer) gfPreventUpdate = False End Sub Private Sub Checkbox1_LostFocus() ' in case user tabs to and away from control without updating it gfPreventUpdate = False End Sub [/CODE] This surprisingly small amount of code seems to do the trick. If you are already doing something in the control's Click or AfterUpdate events, you can optionally set the flag back to false there also instead of in the BeforeUpdate event. There may be other events where the flag needs to be set back to false which I haven't discovered yet. One additional thing I found is that if I made the record dirty by editing another field first, this could also prevent the crash from occurring by itself. ESquared [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Access
Microsoft Access ADP SQL Server
Checkbox crash
Top