Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Same code work for 1 part and failing for another (Access2003)

    3 hours well wasted figuring out WHY????

    I have 3 check boxes on the form.
    Check1 is alone. (when it is checked - nothing else is suppose to be checked and Report will run for ALL locations)
    Check20 and Check22 have Combos to select values from.

    When one is checked - combo should appear (for value selection) and otrher 2 check controls need to be un-checked.

    Check20 has identical code as Check22 - however coed for Check20 works perfectly and code for Check22 doesn't work at all.

    Please, take a look!


    Private Sub Check1_AfterUpdate()
    If Me.Check1.Value = True Then Me.Combo22.Visible = False
    If Me.Check1.Value = True Then Me.Combo20.Visible = False
    If Me.Check1.Value = True Then Me.Check20.Value = False
    If Me.Check1.Value = True Then Me.Check22.Value = False
    Repaint
    End Sub

    Private Sub Check22_AfterUpdate()
    If Me.Check22.Value = True Then Me.Check1.Value = False
    If Me.Check22.Value = True Then Me.Check20.Value = False
    If Me.Check22.Value = True Then Me.Combo22.Visible = True Else Me.Combo22.Visible = False
    If Me.Check22.Value = True Then Me.Combo20.Visible = False
    Repaint
    End Sub

    Private Sub Check20_AfterUpdate()
    If Me.Check20.Value = True Then Me.Check1.Value = False
    If Me.Check20.Value = True Then Me.Check22.Value = False
    If Me.Check20.Value = True Then Me.Combo20.Visible = True Else Me.Combo20.Visible = False
    If Me.Check20.Value = True Then Me.Combo22.Visible = False
    Repaint
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    Open the form in design view.
    Select the Check22 check box.
    Activate the Event tab of the Properties windows.
    Make sure that [Event Procedure] is selected in the After Update box.
    Click the ... button to the right of the dropdown arrow in the After Update box.
    This should take you to the Check22_AfterUpdate procedure.
    Switch back to Access, then save and close the form.
    Does the code work now?

  3. #3
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    It is amazing! I thought if I am copying one and re-naming - it will preserve all the features af the first one but of course...name!

    THANKS!

  4. #4
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    Another 'thing'...

    Now when everything is working I need to use code written on form

    If Me.Check1.Value = True Then
    Call FIRMWIDE_DATA

    If Me.Check22.Value = True Then
    Call RE_LB_DATA

    If Me.Check20.Value = True Then
    Call LB_DATA
    End If
    End If
    End If

    Even I can see Value is true -1 it bypasses Call and goes to the end.


    All 3 Public Subs are in separate modules and I was able to call them before I had added new Check and Combo.
    Thanks

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    I think you want this:

    If Me.Check1.Value = True Then
    Call FIRMWIDE_DATA
    ElseIf Me.Check22.Value = True Then
    Call RE_LB_DATA
    ElseIf Me.Check20.Value = True Then
    Call LB_DATA
    End If

  6. #6
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    It is a blast to have someone who actually knows what I wanted! Because I don't! THANK YOU!

  7. #7
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    Hi! Another trouble!
    If I take this piece nad check the box and select value in combobox
    then
    uncheck the check box and check it again - combobox will appear with last value selected and I need it empty.

    I had tried everything on the list toclear it and it doean't work.
    Please, look into it

    Private Sub Check20_AfterUpdate()
    If Me.Check20.Value = True Then Me.Check1.Value = False
    If Me.Check20.Value = True Then Me.Check22.Value = False
    If Me.Check20.Value = True Then Me.Combo20.Visible = True Else Me.Combo20.Visible = False
    If Me.Check20.Value = True Then Me.Combo22.Visible = False
    Repaint
    End Sub

    I though Repaint should do it. But I have user Reequery and Old Value=False etc. No Luck!

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    Try replacing the line

    If Me.Check20.Value = True Then Me.Combo20.Visible = True Else Me.Combo20.Visible = False

    with the following:

    If Me.Check20.Value = True Then
    Me.Combo20.Visible = True
    Else
    Me.Combo20.Visible = False
    Me.Combo20 = Null
    End If

    This clears the combo box at the same time it's hidden. Next time it is displayed, it should still be clear.

  9. #9
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Same code work for 1 part and failing for another (Access2003)

    Thanks so much!

Posting Permissions

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