Re: Enable/Disable controls on form
- From: Gillian <Gillian@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 19 Jul 2006 05:17:02 -0700
Hey Douglas,
It's Ok, your code works really well. Perfectly in fact for what I want.
Just for info, what I have is the four fields: name, qualification, age and
years of experience which are already enabled so the inputter can put one
person's details in no problem because there will always be one person. But,
if there is another person's details to add, then by clicking the command
button, it brings up four same controls but named slightly differently so
that a second person's details can be entered. I'm going to use the same code
to add a third person and a fourth. What I didn't want is if there isn't a
third or fourth person, then those controls remain disabled but they are
enabled if another record has a second/third/fourth person.
I hope this straightens my question out and many thanks for your help.
"Douglas J. Steele" wrote:
Susan may have been thinking of some other development environment, because.
as far as I'm aware, there is no HasData property for controls in Access.
Try:
Private Sub Form_Current()
Me.PPD2_Name.Enabled = Len(Me.PPD2_Name & vbNullString) > 0
Me.PPD2__Qualification.Enabled = Len(Me.PPD2__Qualification & vbNullString)
0Me.PPD2_Age.Enabled = Len(Me.PPD2_Age & vbNullString) > 0
Me.PPD2_Years_of_Experience.Enabled = Len(Me.PPD2_Years_of_Experience &
vbNullString) > 0
End Sub
I am puzzled, though, as to what you're trying to do. If it's a new record,
obviously it's not going to have any data in it. Doing what you're doing
means you won't be able to provide the data. (Although, of course, you
should never be storing calculated fields such as Age and Year of Experience
since they're constantly changing)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Gillian" <Gillian@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:992C593A-677B-4554-86B0-33E75B534C07@xxxxxxxxxxxxxxxx
Hi SusanV,to
I'm being a bit stupid here but where you've got .HasData, am I supposed
replace that with something because when I pasted your code and ran it, athe
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
Me.PPD2_Years_of_Experience.HasDatavalue 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 =
data - if
(I'm assuming you mean each control is enabled if THAT control has
controlsit 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
remainusing 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
areenabled even though there is no data in them.
What I want to happen is if the controls have data in them, then they
in aenabled and shown with the data but if there is no data in them (i.e.
new record) then the controls are disabled.
Thanks in advance.
- References:
- Re: Enable/Disable controls on form
- From: SusanV
- Re: Enable/Disable controls on form
- From: Gillian
- Re: Enable/Disable controls on form
- From: Douglas J. Steele
- Re: Enable/Disable controls on form
- Prev by Date: Re: Enable/Disable controls on form
- Next by Date: Re: Using Dlookup and Dmax with dates
- Previous by thread: Re: Enable/Disable controls on form
- Next by thread: Re: Enable/Disable controls on form
- Index(es):