Results 1 to 9 of 9
  1. #1
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70

    disabling fields

    Hi everyone



    i would like to know on which event would i need to put some code in order to display some functionality.


    basically this is what i would like to do , if a person uses the search text box i would like my start date , end date text boxes and 3 other combo boxes to be disabled.

    but should the user select a start date first , then i would only like for the search text box to be disabled.


    i have managed to do the first option but it gets tricky as when the cursor loses focus on the text box my other fields do not enable.


    please help

    much appreciated

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    First set the controls to disabled or not visible (your choice) with the on current event.
    Then make the ones you want activated (visible or enabled) with the after update event for the start date.

  3. #3
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    this is what i have did to disable the other fields
    Code:
    Private Sub Search_Click()
    If (Search.Text <> " ") Then
                 Me.Search.Enabled = True
                 Me.StartDate.Enabled = False
                 Me.EndDate.Enabled = False
                 Me.Combo1.Enabled = False
                 Me.Combo53.Enabled = False
                 Me.Combo72.Enabled = False
    End If
    End Sub
    now i am trying to figure out how to enable the other fields should the search box lose its focus.

    i have tried using the lost focus for the search box but it doesn't seem to be working

  4. #4
    sireesha is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    50
    try the above code in searchtextbox gotfocus
    exrivate sub search_textbox_gotfocus()
    me.search.enable=true

    end sub
    and
    also like startdate_gotfocus
    other controls enable false
    i think its working. give me a reply

  5. #5
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    Hi sireesha

    thanks for the reply

    i shall try what you have told me to do... just one question...

    wont the enable field be enabled and not enable lol

    but thanks again appreciate it

  6. #6
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Some thoughts: this is not as straightforward as it first seems. First consider the initial condition. If both the search text and the start date are null/empty then the user is given the choice of either control; in other words both controls must be enabled. If either one has a non null value then the controls must be disabled according to the rules. If both have values, what happens? (Note: the dates and other combo boxes may be considered as a set.)

    Now consider the reaction as the user enters/selects values. I suggest using the before update event since controls are being disabled/enabled.

    Before update of search text.
    IF Trim(Nz(searchtext,"")) = "" THEN enable start date, etc. ELSE disable start date, etc.

    Before update of start date
    IF Trim(Nz(startdate, "")) = "" THEN enable search text ELSE disable search text.

    The Trim(Nz( ... function may not be the best way of testing for an empty control value; use whatever is most appropriate.

  7. #7
    sireesha is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    50
    Quote Originally Posted by Compufreak View Post
    Hi sireesha

    thanks for the reply

    i shall try what you have told me to do... just one question...

    wont the enable field be enabled and not enable lol

    but thanks again appreciate it
    Hi,

    if searchtext box is enabled=false all other fields are enable=true
    like startdate box is enabled=false all other fields are enable=true
    these related code should write it for those textbox gotfocus.

  8. #8
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    My advice? Forget the GotFocus event!

  9. #9
    Compufreak is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    70
    rob is correct , trying your choice now rob

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Disabling Fields
    By dolovenature in forum Programming
    Replies: 2
    Last Post: 09-16-2012, 07:45 PM
  2. Disabling fields
    By bursteffect in forum Access
    Replies: 1
    Last Post: 08-30-2012, 12:54 PM
  3. Disabling fields
    By jle0003 in forum Access
    Replies: 4
    Last Post: 06-06-2012, 09:39 AM
  4. Enabling and disabling fields
    By SgtSaunders69 in forum Programming
    Replies: 9
    Last Post: 12-27-2011, 06:11 PM
  5. Disabling a control
    By NOTLguy in forum Forms
    Replies: 5
    Last Post: 10-31-2010, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums