Enabling Fields in Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combobox valuelist field that is needs to be enabled in my subform
when another field is selected (Yes/No)

Eg:
If [Field A] = true then [Field B] = enabled otherwise [Field B] is not
enabled

I'm pretty sure of the If statement, but I'm confused as to where this code
should be built Field A or Field B.

Do this type of validation rule have to be copied to the table design as well?

Thanks in advance...


T
 
Actually, you hasve to put code in two places ---
1. Put the following code in FieldA AfterUpdate event:
If Me!FieldA = True Then
Me!FieldB.Enabled = True
Else
Me!FieldB.Enabled = False
End If

2. Put the same code in the form's On Current event.

You need to do 2 so correctly enable FieldB when the form opens and when you
navigate through records.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
In addition to steve's reply you can also put it in one line:

me![fieldB].enabled= not me![fieldA]

but indeed place it in the two sections steve mentioned

hth
 
There is still an issue with the latter half of the code
Me!FieldB.Enabled=False is coming up as an error in the (On Current)

1. Does it matter that this is a subform of a main form?
2. Does it matter whether the Enabled Property for FieldB is already set at
yes or no?

Steve said:
Actually, you hasve to put code in two places ---
1. Put the following code in FieldA AfterUpdate event:
If Me!FieldA = True Then
Me!FieldB.Enabled = True
Else
Me!FieldB.Enabled = False
End If

2. Put the same code in the form's On Current event.

You need to do 2 so correctly enable FieldB when the form opens and when you
navigate through records.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




T.Kay said:
I have a combobox valuelist field that is needs to be enabled in my subform
when another field is selected (Yes/No)

Eg:
If [Field A] = true then [Field B] = enabled otherwise [Field B] is not
enabled

I'm pretty sure of the If statement, but I'm confused as to where this
code
should be built Field A or Field B.

Do this type of validation rule have to be copied to the table design as
well?

Thanks in advance...


T
 
It sounds like you put the code in the main form's On Current when you
really need to put it in the subform's On Current event. If that does not
work, are FieldA and FieldB on the main form or subform?

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)



T.Kay said:
There is still an issue with the latter half of the code
Me!FieldB.Enabled=False is coming up as an error in the (On Current)

1. Does it matter that this is a subform of a main form?
2. Does it matter whether the Enabled Property for FieldB is already set
at
yes or no?

Steve said:
Actually, you hasve to put code in two places ---
1. Put the following code in FieldA AfterUpdate event:
If Me!FieldA = True Then
Me!FieldB.Enabled = True
Else
Me!FieldB.Enabled = False
End If

2. Put the same code in the form's On Current event.

You need to do 2 so correctly enable FieldB when the form opens and when
you
navigate through records.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




T.Kay said:
I have a combobox valuelist field that is needs to be enabled in my
subform
when another field is selected (Yes/No)

Eg:
If [Field A] = true then [Field B] = enabled otherwise [Field B] is not
enabled

I'm pretty sure of the If statement, but I'm confused as to where this
code
should be built Field A or Field B.

Do this type of validation rule have to be copied to the table design
as
well?

Thanks in advance...


T
 
Back
Top