Steve,
Firstly, "Thank You" very much for all your help. I wanted to tell you that
I tried the conditional formatting using enable and it worked i.e. each
record is treated differently. The only problem though is if the first record
is not affected by a condition, the background and font colour are less dark
for subsequent record when the condition is met i.e. a User could see the
default data entry in the underlying table. SInce they can't change it
though, your proposed solution works fine.
Also, as per my question below regarding your code.....FYI......I had tried
to use code as initially suggested, but I couldn't get it to work even though
it appeared like it ran. Below is the final code I had put together. For my
learnings, can you tell me why this did not work.
Pele
Private Sub Form_Current()
Dim thisform As Form
Set thisform = Forms![frm_update rate tbl_main]![frm_update rate table].Form
If (Forms![frm_update rate tbl_main]![frm_update rate
table].Form.[labor_type_cd] = 2 Or Forms![frm_update rate
tbl_main]![frm_update rate table].Form.[labor_type_cd] = 7) Then
'prevent data entry into hourly rate, Vacation weeks and Other Weeks
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[hourly
rate].Locked = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Vacation
weeks].Locked = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Other
weeks].Locked = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Monthly
rate].Enabled = "true"
End If
If (Forms![frm_update rate tbl_main]![frm_update rate
table].Form.[labor_type_cd] = 1 Or Forms![frm_update rate
tbl_main]![frm_update rate table].Form.[labor_type_cd] = 3 Or
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[labor_type_cd]
= 6) Then
'prevent data entry into Monthly Rate
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[hourly
rate].Enabled = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Vacation
weeks].Enabled = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Other
weeks].Enabled = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Monthly
rate].Locked = "true"
End If
If (Forms![frm_update rate tbl_main]![frm_update rate
table].Form.[labor_type_cd] = 5 Or Forms![frm_update rate
tbl_main]![frm_update rate table].Form.[labor_type_cd] = 4) Then
'prevent data entry to following fields if Manpower employee
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Vacation
weeks].Locked = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Other
weeks].Locked = "true"
Forms![frm_update rate tbl_main]![frm_update rate table].Form.[Monthly
rate].Locked = "true"
End If
End Sub
Steve Schapel said:
Pele,
Hopefully you have now got this one sorted out. On reading this last
post of yours, it appears that you didn't see my previous reply. If you
still need any help with it, please post back with the code you are
currently using.
--
Steve Schapel, Microsoft Access MVP
Hello Steve,
Please let me know what your new thoughts are regarding this problem.
By the way, the way you've written your code (see below). does not give me
the opportunity to specify whether the textbox's Locked Property is True or
False (same for the Enabled property).
By the way, the Labor_type_cd is correct. I'd mistakenly refered to it as
Labor Rate Code.
Private Sub Form_Current()
'prevent data entry into hourly rate, Vacation weeks and Other Weeks
Me.[hourly rate].Locked = ([labor_type_cd] = 2 Or [labor_type_cd] = 7)
Me.[Vacation weeks].Locked = ([labor_type_cd] = 2 Or [labor_type_cd] = 7)
Me.[Other weeks].Locked = ([labor_type_cd] = 2 Or [labor_type_cd] = 7)
Me.[Monthly rate].Enabled = ([labor_type_cd] = 2 Or [labor_type_cd] = 7)