Results 1 to 12 of 12
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable Control(s) (A2k2)

    Good Morning,

    I want to disable certain controls of a form if they are dirty. Enable them if it's a new record. I'm using the following code and it works except for the "IF" part. Can someone please help me?
    <pre> Select Case GetUser()
    Case "yhusman", "jburnet", "sharrel", "kdavids"
    Date_Referral_Recd.Enabled = True
    Date_Rejected.Enabled = True
    Date_Opened.Enabled = True
    Date_Closed.Enabled = True
    Reassigned_To.Enabled = True
    Case Else
    If Me.NewRecord Then
    Me.Date_Referral_Recd.Enabled = True
    Me.Date_Rejected.Enabled = False
    Me.Date_Opened.Enabled = True
    Me.Date_Closed.Enabled = True
    Me.Reassigned_To.Enabled = True
    End If
    Date_Referral_Recd.Enabled = False
    Date_Rejected.Enabled = False
    Date_Opened.Enabled = False
    Date_Closed.Enabled = False
    Reassigned_To.Enabled = False
    End Select
    </pre>



    I'm certian I've written it wrong...but can't see the light.

    Thanks,
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Disable Control(s) (A2k2)

    you probably meant to put the End if at the end of the second group instead it is at the end of the first group


    If Me.NewRecord Then
    Me.Date_Referral_Recd.Enabled = True
    Me.Date_Rejected.Enabled = False
    Me.Date_Opened.Enabled = True
    Me.Date_Closed.Enabled = True
    Me.Reassigned_To.Enabled = True

    Else

    Date_Referral_Recd.Enabled = False
    Date_Rejected.Enabled = False
    Date_Opened.Enabled = False
    Date_Closed.Enabled = False
    Reassigned_To.Enabled = False

    End if

    End Select

    I think this should fix it

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

    Re: Disable Control(s) (A2k2)

    I think you want this:
    <pre> Select Case GetUser()
    Case "yhusman", "jburnet", "sharrel", "kdavids"
    Date_Referral_Recd.Enabled = True
    Date_Rejected.Enabled = True
    Date_Opened.Enabled = True
    Date_Closed.Enabled = True
    Reassigned_To.Enabled = True
    Case Else
    If Me.NewRecord Then
    Me.Date_Referral_Recd.Enabled = True
    Me.Date_Rejected.Enabled = False
    Me.Date_Opened.Enabled = True
    Me.Date_Closed.Enabled = True
    Me.Reassigned_To.Enabled = True
    Else
    Date_Referral_Recd.Enabled = False
    Date_Rejected.Enabled = False
    Date_Opened.Enabled = False
    Date_Closed.Enabled = False
    Reassigned_To.Enabled = False
    End If
    End Select
    </pre>

    You forgot the Else, and placed the End If incorrectly.

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Control(s) (A2k2)

    Hans,

    Thanks for the suggestion. I've applied it but it still doesn't do what I need it to do.

    I need those 5 fields to be disabled if the record is dirty .... if it's a NEW record, the 5 fields can be accessed, however, once the fields are filled in, they MUST be disabled.

    I've made the changes....see below.....but I must still be missing an important part.

    <pre>Select Case GetUser()
    Case "yhusman", "jburnet", "sharrel", "kdavids"
    Date_Referral_Recd.Enabled = True
    Date_Rejected.Enabled = True
    Date_Opened.Enabled = True
    Date_Closed.Enabled = True
    Reassigned_To.Enabled = True
    Case Else
    If Me.NewRecord Then
    Me.Date_Referral_Recd.Enabled = True
    Me.Date_Rejected.Enabled = True
    Me.Date_Opened.Enabled = True
    Me.Date_Closed.Enabled = True
    Me.Reassigned_To.Enabled = True
    Else
    Date_Referral_Recd.Enabled = False
    Date_Rejected.Enabled = False
    Date_Opened.Enabled = False
    Date_Closed.Enabled = False
    Reassigned_To.Enabled = False
    End If
    End Select
    </pre>



    Once again, thanks for your help.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Disable Control(s) (A2k2)

    Where did you put this code?

  6. #6
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Control(s) (A2k2)

    In the OnLoad Event of the form.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Disable Control(s) (A2k2)

    Try putting it in the On Current event instead. That way, the controls will be enabled/disabled as the user moves from record to record.

  8. #8
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Control(s) (A2k2)

    I'm asking for my own information, but is Me.NewRecord the proper way to check if a record really is "new"?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

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

    Re: Disable Control(s) (A2k2)

    Yes. NewRecord is True if the current record has never ever been saved. It doesn't matter whether the user has entered anything in the record yet or not.

  10. #10
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Control(s) (A2k2)

    So shouldn't the code test for If Me.NewRecord = True ?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

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

    Re: Disable Control(s) (A2k2)

    NewRecord is a Boolean property, so its value is already True or False.

    If Me.NewRecord Then

    is equivalent to

    If Me.NewRecord = True Then

  12. #12
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Control(s) (A2k2)

    Thanks Hans [img]/forums/images/smilies/smile.gif[/img]
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

Posting Permissions

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