Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011

    Unanswered: Lock Field Based on Data in Other Field and Color

    In my form I have 2 fields, Temp Rate and Earnings. My code locks either field based on entry, so if they enter a temp rate, the earnings get locked, if they enter earnings the temp rate gets locked and the locked field gets the background color changed.

    This is my code for the temp rate field, the earnings is the same, just with the field names changed:

    If Me.[Temp Rate].Value = 0# Then Me.Earnings.Locked = False Else Me.Earnings.Locked = True
    If Me.[Temp Rate].Value = 0# Then Me.Earnings.BackColor = vbWhite Else Me.Earnings.BackColor = vbBlue

    My probem is this, I am using Continuous Forms for multiple enteries, so, when the first line entry is made it colors and locks everything until the next line entry is made, but, after the second line entry is made, it unlocks the first line entry. What I am trying to do is make it so that it only locks that single line item and doesn't change when additional lines are added and changed.

    What should be happening is
    line 1, temp rate is 25 earnings is locked.
    line 2 temp rate is 0 earnings in line 2 only is unlocked (and doesn't affect line 1) earnings is 50 and temp rate on line 2 only is locked.

    I am pulling my hair out on this one, please help.

    Also, I have read other threads, which have got me this far in functionality, I just need to close the gap.
    Last edited by ericsmith1172; 06-30-11 at 09:51. Reason: Forgot to Post Info

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    As far as coulours are concerned you can use the Conditional Format features, they works on datasheet view and contituous view.

    As for locking/unlocking controls, you can perform the test on the GotFocus event of the controls, the values returned will be those of the current row and you don't care whether the other rows of controls are locked/unlocked at that moment as only one row can be the current one.
    Have a nice day!

  3. #3
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Or, if you want it to be visually obvious that one field or the other is not usable, you can once again use Conditional Formatting and Disable the not-to-be-used Field.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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