FRUSTRATED: Enable field depending on value of another

  • Thread starter Thread starter PsyberFox
  • Start date Start date
P

PsyberFox

Hi,

I have the following three subs (amongst others):
Private Sub Form_Current()
If Trim(Title.Value) = "Other" Then
TitleOther.Enabled = True
TitleOther.SetFocus
Else
TitleOther.Enabled = False
End If

If MedicalAid = "OTHER" Then
MedicalAidOther.Enabled = True
MedicalAidOther.SetFocus
Else
MedicalAidOther.Enabled = False
End If
End Sub

Private Sub Title_AfterUpdate()
If Trim(Title.Value) = "Other" Then
TitleOther.Enabled = True
TitleOther.SetFocus
Else
TitleOther.Enabled = False
PatientName.SetFocus
End If
End Sub

Private Sub MedicalAid_AfterUpdate()
If MedicalAid = "OTHER" Then
MedicalAidOther.Enabled = True
MedicalAidOther.SetFocus
Else
MedicalAidOther.Enabled = False
MedicalAidNumber.SetFocus
End If
End Sub

The Title one works perfectly as it should, i.e. enabling the Title-Other
field if "Other" is selected - this list is contained in a value list in the
tblPatient table; however the MedicalAid one is not working - it gets its
values from another table called tblMedicalAid where btw the description is
OTHER (caps). Am I missing something here?

Thank you for any help!
 
Morning Marshall,

I don't know if I understand your one concern properly. I don't have a field
that is bound to fields in more than one table. The MedicalAid is a combobox
(obviously drop-down on my form) of which the record source is the
tblMedicalAid table. When a user selects OTHER from this list, it should
enable the MedicalAidOther field, which is simply a text box where the Other
Medical Aid can then be entered. If the user selects a Medical Aid other than
OTHER it should disable the Medical Aid Other text box...

Hope this sheds some more light on my problem.

Rgds,
W
 
It sounds as if your combo has 2 columns. The first is probably hidden and
is the bound column which means that it's value (probably the MedicalAid ID)
is the one being stored in whatever table your Form is bound to. The second
is the description you see in the combo. You need to refer to this second
column in your if statement. The column's are indexed starting at 0 for the
first one so try:

If MedicalAid.Columns(1) = "OTHER" Then

HTH

Jon
 
Thank you so much! Works perfect as you're 100% correct - there is a hidden
column (with ID).
Blud-e marvelous!
W
 
Back
Top