Clear Empty Record on Continuous Subform

Reese

Registered User.
Local time
Yesterday, 22:28
Joined
Jan 13, 2013
Messages
387
I have a continuous subform that just has one combo box as a control (named docentTxt). It is designed to select facilitators who have went on the given event (which is in the main form). Here is the current table/relationship structure:

The Event Information table has Event_ID as the primary key and is what the main form is based on. The list of facilitators is in FacilitatorTable and has Facilitator_ID as the primary key. The FacilitationTable is what the subform is based on and links the events with facilitators with the following fields: Facilitation_ID (the table's primary key), Event_ID and Facilitator_ID.

As soon as I begin typing in the subform's combo box, a new entry is made in the FacilitationTable and the appropriate links are made based on which facilitator is chosen from the combo. That works fine and is great.

The problem is that if I delete the content of a combo box in the continuous form, that record still exists in the table--just blank in the Facilitator_ID field--and makes it so that there is a blank entry in the subform. Is there anyway that I can force Access to delete a record in the FacilitationTable if the combo box is blank after an update?

So far I have tried this, but it doesn't do anything:

Code:
Private Sub DocentTxt_AfterUpdate()

If Me.DocentTxt = "" Then
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdDeleteRecord
    DoCmd.SetWarnings True
    DoCmd.RefreshRecord
End If

End Sub

Thanks.
 
Try

If Len(Me.DocentTxt & vbNullString) = 0 Then
...

This will catch null and an empty string

Edited

On the other hand maybe

If IsNull(Me.DocentTxt) then
..

is sufficient as who would ever enter an empty string "" when they were trying to erase the entry
 
Last edited:
Sneuberg,

Your second suggestion worked perfectly. I had used "" originally because I've used that in the past to indicate an empty text field. I guess it doesn't work in this case, however. Thanks!
 

Users who are viewing this thread

Back
Top Bottom