Highlight Locked Fields in datasheet

  • Thread starter Thread starter Charles D Clayton Jr
  • Start date Start date
C

Charles D Clayton Jr

I have a main form with a subform that the user views in the datasheet
style. There are some fields that they cannot enter data into which
have been locked. Is it possible to highlight those fields that they
cannot enter data into? If so, how would one go about it. By
highlight I mean in some form or fashion identifing those fields that
are off limits (or, conversely, those fields that are required).

I am running A2K

Thanks,

Charles D Clayton Jr
 
Hi Charles

There are many textbox properties you can use to make certain fields appear
different from others. These include:
BackColor (colour of the background)
ForeColor (colour of the text)
Font (various properties)
BorderStyle (solid/dotted/dashed line)
BorderColor (colour of the border line)
BorderWidth (thickness of the border line)

If you lock/unlock controls at run-time using code, then all these
properties can also be changed in code.

You can also set Enabled = False (or "No" from the property sheet) and then
the locked control cannot even get the focus.
 
Thanks for your suggestions. I will look into them. Do you have a
sample snipet of code for locking/unlocking at run-time?

Charles

Graham Mandeno said:
Hi Charles

There are many textbox properties you can use to make certain fields appear
different from others. These include:
BackColor (colour of the background)
ForeColor (colour of the text)
Font (various properties)
BorderStyle (solid/dotted/dashed line)
BorderColor (colour of the border line)
BorderWidth (thickness of the border line)

If you lock/unlock controls at run-time using code, then all these
properties can also be changed in code.

You can also set Enabled = False (or "No" from the property sheet) and then
the locked control cannot even get the focus.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Charles D Clayton Jr said:
I have a main form with a subform that the user views in the datasheet
style. There are some fields that they cannot enter data into which
have been locked. Is it possible to highlight those fields that they
cannot enter data into? If so, how would one go about it. By
highlight I mean in some form or fashion identifing those fields that
are off limits (or, conversely, those fields that are required).

I am running A2K

Thanks,

Charles D Clayton Jr
 
Hi Charles
Thanks for your suggestions. I will look into them. Do you have a
sample snipet of code for locking/unlocking at run-time?

Simply set the properties in VBA code. For example:

txtPrice.Enabled = False
txtPrice.Locked = True

If you want to lock/unlock/change the appearance of many controls, you might
wish to write a small function to make all the changes:

Sub LockControl( c as Control, fNewState as Boolean )
with c
.Locked = fNewState
.Enabled = Not fNewState
If fNewState then
.BackColor = vbYellow
Else
.backColor = vbWhite
End If
End With
End Sub
 
Back
Top