In my brain tumor database I have a surgery data form that is embedded in the demographics form. The surgery data form is based on a query called qrySurgeryData. There are two fields in the surgery data form to enter the type of surgical procedure, planProc and planProcOther. planProc is a combo box with a list of procedures which includes “other” as one of the choices. PlanProcOther is a textbox where the user can type the name of a procedure if “Other” was selected in the planProc field.
[FONT=Verdana][COLOR=black]I want to control the use of the planProcOther field in the Surgery Data Form. The PlanProcOther field is disabled until the user selects “Other” from planProc comboBox. When the user enters text in the planProcOther field it creates a new record in tblPlanProcOther.
Here’s the code minus the error handling parts.
Code:Private Sub cboPlanProc_AfterUpdate() 'Enable the planProcOther field and move the cursor when OTHER is selected. If Me.planProc = "other" Then Me.planProcOther.Locked = False Me.planProcOther.Enabled = True Me.planProcOther.SetFocus
But now comes the hard part. Suppose the user changes his/her mind and changes the planProc field from “other” to something else? I need code that checks to see if a new the entry was made in tblPlanProcOther and if so to delete it. If not, just reset the enabled property in the planProcOther field to false.
I imagine the code would be assigned to the On Dirty event in planProc and would look something like this, again minus the error handling:
I need help filling in the details. Can someone please help me out?Code:Private Sub cboPlanProc_Dirty (Cancel As Integer) 'Check to see if there is a record in tblPlanProcOther with the same 'caseNUM as the current case number If ***there is a record in tblPlanProcOther with the same caseNum as the current case number*** Then ***Code to delete it goes here*** Me.planProcOther.Enabled = False Else Me.planProcOther.Enable = False End IF End Sub