borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Add User Document)Next Topic (Error when connect VB to asp) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Check Boxes
Poster Message
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305

icon Check Boxes  Archived to Disk

Can anyone help me out with this:-

The main Form (DatabaseEntry.frm) has on it a check box (DDCheck) and in the DDCheck_Click I have the following code:-



Private Sub DDCheck_Click()

'Check for Direct Debit Check and display reminder
If DDCheck.Value = Checked Then
      DetailsReview.Show
      DatabaseEntry.Hide
      Unload DatabaseEntry
End If

End Sub

And so to the problem in hand.  If DatabaseEntry loads and the DDCheck is set to checked, DatabasEntry promptly unloads causing an "Object was unloaded" error.  The problem is that the CheckBox is linked to a database, therfore if the first record of the database has DDCheck set as Checked, the code is executed immediately and the program crahes and burns.  I need the code only to be executed if the CheckBox is physically changed, not when the form first loads.

Have a go at that if ya dare!!!

____________________________
I don't wanna die... but I ain't keen on livin' either

30-07-2002 at 10:25 AM
View Profile Send Email to User Show All Posts | Quote Reply
RedRock
Level: Guest

icon Re: Check Boxes  Archived to Disk

Well, if you can make sure that checkbox doesn't have the focus when the page loads then you can wrap your IF statement in something like this:

If Screen.ActiveControl = DDCheck Then
  If DDCheck.Value = Checked Then
  . . .
  End If
End If

Basically, if that checkbox doesn't have the focus on page load then the only way it will get the focus is through user interaction (a click) or through SetFocus().

I guess another way would be to check all the MouseDown/Up KeyDown/Up events and keep track of them. Yuck.

30-07-2002 at 01:21 PM
| Quote Reply
Coyote
Level: Guest

icon Re: Check Boxes  Archived to Disk

See my response to this same question Under the Database category.
Hope that resolves your problem and answers your question.

>>>Coyote<<<

30-07-2002 at 03:23 PM
| Quote Reply
AndreaVB Forum : VB General : Check Boxes
Previous Topic (Add User Document)Next Topic (Error when connect VB to asp) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder