Re: Enable/Disable controls on form



Hey Susan,

No worries, I often have days like that!!!

Thanks again.

"SusanV" wrote:

Sorry - HasData is for Reports, not Forms - too early in the morning!
<pours coffee>

My apologies - try the following instead:


Me.[PPD2_Name].Enabled = (Nz(Me.[PPD2_Name], "") <> "")

(repeat for other fields)


Again, sorry for any confusion!
--
hth,
SusanV


"Gillian" <Gillian@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:992C593A-677B-4554-86B0-33E75B534C07@xxxxxxxxxxxxxxxx
Hi SusanV,

I'm being a bit stupid here but where you've got .HasData, am I supposed
to
replace that with something because when I pasted your code and ran it, a
message appears saying "Method or Data Member not found". The data in the
four controls would be different for each record by the way.

Here is what I pasted in:-

Private Sub Form_Current()

Me.PPD2_Name.Enabled = Me.PPD2_Name.HasData
Me.PPD2__Qualification.Enabled = Me.PPD2__Qualification.HasData
Me.PPD2_Age.Enabled = Me.PPD2_Age.HasData
Me.PPD2_Years_of_Experience.Enabled = Me.PPD2_Years_of_Experience.HasData

End Sub

Thanks.

"SusanV" wrote:

Hi Gillian,

Set the enabled property using the OnCurrent event of the form, based on
the
value of the field:

Me.PPD2_Name.Enabled = Me.PPD2_Name.HasData
Me.PPD2__Qualification.Enabled = Me.PPD2__Qualification.HasData
Me.PPD2_Age.Enabled = Me.PPD2_Age.HasData
Me.PPD2_Years_of_Experience.Enabled = Me.PPD2_Years_of_Experience.HasData

(I'm assuming you mean each control is enabled if THAT control has data -
if
it is based on a different control, modify the above accordingly.)

--
hth,
SusanV


"Gillian" <Gillian@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AF21AA63-AFE3-488F-90A9-50CA36538B81@xxxxxxxxxxxxxxxx
Hi,

I have a command button, which, when clicked enables four other
controls
using the following code:

Me.PPD2_Name.Enabled = True
Me.PPD2__Qualification.Enabled = True
Me.PPD2_Age.Enabled = True
Me.PPD2_Years_of_Experience.Enabled = True

The problem is that when scrolling to a new record, the controls remain
enabled even though there is no data in them.

What I want to happen is if the controls have data in them, then they
are
enabled and shown with the data but if there is no data in them (i.e.
in a
new record) then the controls are disabled.

Thanks in advance.






.