Results 1 to 6 of 6

Thread: Problem with checkboxes[RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    163

    Resolved Problem with checkboxes[RESOLVED]

    Ok here's my problem,

    I have a checkbox, on formload it checks a database to see if it's checked. The problem is if it is checked it's asked the user to re-fill out the inputforms because the form will put a check in it on load triggering the events. The hard part is the checkbox also contains the uncheck code which zero's everything out. How can i make it check on load and still have the uncheck capabilities. I've tried several different things to no avail... I've tried...

    With mytable
    If !mycheckbox = true Then
    Exit Sub
    end with

    the problem with that is it kills the functionality of the uncheck because when the box is clicked it checks the table, see's it's checked and then exits.
    Last edited by trinic; Feb 10th, 2007 at 01:20 AM. Reason: resolved
    If this post has helped you please rate it by clicking the scales to the left of this post!

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Problem with checkboxes

    Add a Static flag.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Check1_Click()
    4. Static IsAlreadyLoaded As Boolean
    5.  
    6. ' Do stuff
    7. If IsAlreadyLoaded Then
    8.     MsgBox "Put your uncheck code here"
    9. Else
    10.     IsAlreadyLoaded = True
    11. End If
    12. End Sub
    13.  
    14. Private Sub Form_Load()
    15.     Check1.Value = vbChecked
    16. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    163

    Re: Problem with checkboxes

    not quite... this is what i'm talking about, see if you can make the input box only popup when you check the box
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Check1_Click()
    4. Static IsAlreadyLoaded As Boolean
    5. Dim nick As String
    6.  
    7.  nick = InputBox("what")
    8. If IsAlreadyLoaded Then
    9.     MsgBox "Put your uncheck code here"
    10. Else
    11.     IsAlreadyLoaded = True
    12.    
    13. End If
    14. End Sub
    15.  
    16. Private Sub Form_Load()
    17.     Check1.Value = vbChecked
    18. End Sub

    not when the form loads
    Last edited by trinic; Feb 10th, 2007 at 12:14 AM.
    If this post has helped you please rate it by clicking the scales to the left of this post!

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Problem with checkboxes

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Check1_Click()
    4.     Static IsAlreadyLoaded As Boolean
    5.     Dim nick As String
    6.    
    7.     ' Common codes
    8.     If IsAlreadyLoaded Then
    9.         'codes you want to run when form is already LOADED
    10.         If Check1.Value = vbChecked Then
    11.             nick = InputBox("what")
    12.         End If
    13.     Else
    14.         'codes you want to run when form is LOADING
    15.         IsAlreadyLoaded = True
    16.     End If
    17.     ' Common codes
    18. End Sub
    19.  
    20. Private Sub Form_Load()
    21.     Check1.Value = vbChecked
    22. End Sub
    Edit:
    In this code, you must change the value of the checkbox from Form_Load. Otherwise the Static value will not change.
    If you want the checkbox to be unchecked when the form loads for first-time, set it to Checked during designtime and in form load write,
    VB Code:
    1. Private Sub Form_Load()
    2.     Check1.Value = vbUnchecked
    3. End Sub
    Last edited by iPrank; Feb 10th, 2007 at 12:39 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Problem with checkboxes

    Possibly using the mouseup event instead of the click?
    VB Code:
    1. Private Sub Check1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. Dim nick As String
    3.  
    4. nick = InputBox("what")
    5. End Sub
    Last edited by Andrew G; Feb 10th, 2007 at 12:43 AM.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    163

    Re: Problem with checkboxes

    ty, exp points added
    If this post has helped you please rate it by clicking the scales to the left of this post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width