Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If witout block (Access2000-03)

    Hi,
    I have 2 combo boxes.
    When value in one is selescted - another should get disabled so value can't be picked out of that one.
    It is either - or!

    So would this be valid? So far it is not working - giving me an error If without BlockIf etc...:

    If ID_Name.Value = True Then BUSINESS_UNIT.Enabled = False
    Else
    If BUSINESS_UNIT.Value = True Then ID_Name.Enabled = False
    End If

    Thanks

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If witout block (Access2000-03)

    You are missing a second End If (it's clearer with indenting):

    If ID_Name.Value = True Then
    BUSINESS_UNIT.Enabled = False
    Else
    If BUSINESS_UNIT.Value = True Then
    ID_Name.Enabled = False
    End If
    End If

    Nick

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

    Re: If witout block (Access2000-03)

    Thank you, Nick.
    I am trying to let user to select from one cmb.box only
    However that code of mine does not disabling anything.
    Am I using wrong property?

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

    Re: If witout block (Access2000-03)

    Try this:

    Private Sub Business_Unit_AfterUpdate()
    Me.ID_Name.Enabled = IsNull(Me.Business_Unit)
    End Sub

    Private Sub ID_Name_AfterUpdate()
    Me.Business_Unit.Enabled = IsNull(Me.ID_Name)
    End Sub

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

    Re: If witout block (Access2000-03)

    Cool!
    But what it does - it let's me pick the value from the first one.
    Then it let's me pick value from the second one and when value in second one is PICKED - it greys out the FIRST one.

    I am going to play with it now. Thanks any changes you can think of - please, pass them onto me.?

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

    Re: If witout block (Access2000-03)

    Here is a slightly fancier version:

    Private Sub Business_Unit_AfterUpdate()
    If IsNull(Me.Business_Unit) Then
    Me.ID_Name.Enabled = True
    Me.ID_Name.SetFocus
    Else
    Me.ID_Name.Enabled = False
    End If
    End Sub

    Private Sub ID_Name_AfterUpdate()
    If IsNull(Me.ID_Name) Then
    Me.Business_Unit.Enabled = True
    Me.Business_Unit.SetFocus
    Else
    Me.Business_Unit.Enabled = False
    End If
    End Sub

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

    Re: If witout block (Access2000-03)

    It does exactly the same thing as I described above.
    It should be like this:
    If value in the first one picked - second gets disabled.
    And vise versa.
    Or maybe if one value was picked - try to touch another and get message 'You are not allowed to select another value'...

    I think first way is cleaner...
    Thanks

    P.S. I had just tried again and I am thinking both are should be enabled (in case they changed their mind and wanted to print Report for another parameter) - so the way is to keep both combo boxes enabled BUT IF value in one was picked - if user tries to pick the value in another one - error message.
    They need to be force to delete the value from the first and pick in the second one IF they happened to change their mind...

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

    Re: If witout block (Access2000-03)

    My code does what you want - see attached demo.
    Attached Files Attached Files

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

    Re: If witout block (Access2000-03)

    Of course...I forgot to set properties of combo boxes to [event procedure] and have the correct ones to it!
    THANKS

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

    Re: If witout block (Access2000-03)

    Yep! I need that message so both are staying Enabled BUT if one value is already picked - if second box touched by accident or on purpose - error message comes up.
    I can see how they can easily pick in a wrong box and the way it is now - no stepping back.
    Thanks

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

    Re: If witout block (Access2000-03)

    They can always clear the combo box, as soon as they tab out of it, the other one will be enabled.

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

    Re: If witout block (Access2000-03)

    I'd tried.
    When I clicked on the button to run the Report second disabled box gor back to enable state.
    But IF they want to clear one they had picked - another one is dead and no way it can be ressurected unless they run Report first...
    Am I wrong?

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

    Re: If witout block (Access2000-03)

    In the demo I posted, all you need to do is clear the combo box that is filled, then press tab. The other one will be enabled instantaneously. If both combo boxes are cleared, both will be enabled. No need to run a report first, or anything like that.

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

    Re: If witout block (Access2000-03)

    Yep! The step of pressing the tab is very inconvenient. Is it avoidable? Thanks

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

    Re: If witout block (Access2000-03)

    If the user doesn't press Tab, Access doesn't know that the combo box has been cleared.

    Another option would be to leave both combo boxes enabled, and to perform a check afterwards, for example in the Before Update event of the form, or in the On Click event of a command button.
    This means that the user can select an item in both combo boxes without problems. The warning will be issued later.

Page 1 of 2 12 LastLast

Posting Permissions

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