Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to erase a field based on a selection in another field

Status
Not open for further replies.

marie515

Technical User
Feb 27, 2004
71
0
0
US
Hi there,

I have a drop down box that contains "types of complaints" received.

If the type of complaint selected is a) "grievance" or b) "access to care", then three other fields are enabled and visible; otherwise they are not.

Now, lets say the user selects grievance on a case and then fills in the other visible/enabled fields, but later determines that they selected 'grievance' in error and it is really a different type of issue that does not need the additional fields populated.

How do I say if any other "type of complaint" is selected other than grievance or access to care, then erase the other three fields?

Thank you....
 
How about something like this....

Select Case me.cboComplaint
Case "grievance"
'any code
Case "access to care"
'any code
Case Else
if me.txtGrievance.Visible then
me.txtGrievance = ""
me.txtGrievance.Visible = False
end if
Ens Select
 
Hi Marie,

I'll assume your form has the objects
cbComplaintType (a combo box)
txtAdditonalField1 (a text box)
txtAdditonalField2 (a text box)
txtAdditonalField3 (a text box)

Firstly set the visible property of your three text boxes to false ... by default, nobody will see them.

You will then need to set up an After Update event on your combo box like this -

Private Sub cbComplaintType_AfterUpdate()

Select Case cbComplaintType.Value
Case "Greivance", "Access to care"
txtAdditionalField1.Visible = True
txtAdditionalField2.Visible = True
txtAdditionalField3.Visible = True

Case Else
txtAdditionalField1.Visible = False
txtAdditionalField2.Visible = False
txtAdditionalField3.Visible = False

End Select

End Sub

Instead of the visible property, you could use the enabled property so they are always there but sometimes enabled for input.

Hope this helps [pipe]
 
Hey Randy .. your post wasn't there when I started typing my reply but we both come up with the same answer so we must be right !!

Cheers [thumbsup2]
 
thanks guys....I give this a try and let you know how it works...thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top