Disable text box via Combo box

  • Thread starter Thread starter Kurt_Cobain67
  • Start date Start date
K

Kurt_Cobain67

Hey,
Can any one see if that can help?

I want to disable certain fields when a certain value is selected in a
combo box.
I have a form called "Expenses" and within that a subform
"GeneralExpenses_subform". On the subform form when you select a value
other than "Mileage" from the combo box "ExpenseType" i want
"VisitMileage","VehicleMileage" and "MileageRate" to be disabled so
that no data can be written in to them on that particluar record.

Cheers

Nathan
 
Kurt,
On the AfterUpdate event of cboExpenseType...

Refresh
VisitMileage.Enabled = cboExpenseType = "Mileage"
MileageRate. Enabled = cboExpenseType = "Mileage"
VehicleMileage.Enabled = cboExpenseType = "Mileage"

Since that will set those fields Enabled/Disabled on EACH subform record, use the same
code in the subform record OnCurrent event.
 
Cheers for that.

I have pasted the code in to AfterUpdate on the combo box and on the
subform in OnCurrent, but the feilds are disabled all thetime no matter
what i select.

Nathan
 
Please provide the code, exactly as you used it...
I'll test my solution in the meantime...
 
Kurt,
Please don't delete any threads from our previous posts. It's convenvenient to see my,
and your, past reponses as we continue the problem determination.
Let's try a more obvious method...

On the combo AfterUpdate event... (use your own field names... I used my own for ex.)
If Service = "Design" Then
WorkDescription.Enabled = False
Else
WorkDescription.Enabled = True
End If

On the subform On Current event
If IsNull(Service) Or Service <> "Design" Then
WorkDescription.Enabled = True
Else
WorkDescription.Enabled = False
End If

I tested this, and it works.
 
Just happen to notice a typo... that initial code should have been.
VisitMileage.Enabled = cboExpenseType <> "Mileage" (not equal rather than equal)
MileageRate. Enabled = cboExpenseType <> "Mileage"
VehicleMileage.Enabled = cboExpenseType <> "Mileage"

If you still have problems, try my later posted code. I tested that.
 
Al said:
Kurt,
Please don't delete any threads from our previous posts. It's convenvenient to see my,
and your, past reponses as we continue the problem determination.
Let's try a more obvious method...

On the combo AfterUpdate event... (use your own field names... I used my own for ex.)
If Service = "Design" Then
WorkDescription.Enabled = False
Else
WorkDescription.Enabled = True
End If

On the subform On Current event
If IsNull(Service) Or Service <> "Design" Then
WorkDescription.Enabled = True
Else
WorkDescription.Enabled = False
End If

I tested this, and it works.
Hey, this works but it enables and disables all of the previous cells
in the record, i want it to disabled and enable the cells in each
individual record, not the whole table.

Cheers

Kurt
 
Such is the nature of forms.
If you changed the color for one field, all records would have that field color.
Any change to a field on a continuous subform or single form is "visibly" applied to
all records.
But... it's the same for single forms. Disable a field and all rceords have that field
disabled... it's just that you don't see the other records in Single like you do in
Continuous. Of course, as you move from record to record, the code enables/disables as
you get there, so it "appears" as though each record has it's "own" disable/enable.

You could use Locking instead, then the "appearance" of the field would not change so
obviously.
 
Back
Top