I have a form that allows the user to select a record from the database's main list of properties when they determine that it matches a record on a new imported spreadsheet. (This requires a manual matching exercise, because several different data sources are to be blended together, and they do not all use the same names for the properties, etc. Needs to be rather user-friendly.)
Here is my code assigned to the On Change event for a combobox cboMatch:
Expand|Select|Wrap|Line Numbers
- Private Sub cboMatch_Change()
- ' Update the related field to the PropIndex of any selected property.
- If IsNull(cboMatch) Then ' Deleting (un-matching) is an option.
- txtPropIndex = Null
- DoCmd.Save
- txtPropIndex.Requery
- Else
- txtPropIndex = cboMatch
- txtPropIndex.Requery
- End If
- End Sub
The updating of txtPropIndex works absolutely fine if an option is selected from the list. However, I also want to make it possible to delete the value in cboMatch, which should then delete the value in txtPropIndex and the underlying table. (This option is a must in case an incorrect match is made.) And for some reason, txtPropIndex will not change to Null. Once a selection is made, it always shows a value; I cannot get it to delete, because it won't accept the Null from cboMatch and I have locked the control.
cboMatch is also programmed to show already-matched property names via On Current:
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Current()
- ' If property is already matched when the record changes,
- ' show the matched property name from tblDCCProperties in the combo box.
- If Not IsNull(txtPropIndex) Then
- cboMatch = txtPropIndex
- Else
- cboMatch = "" ' Otherwise, reset it to blank.
- cboMatch.Requery
- End If
- ' Regardless, the selectable field should be highlighted.
- cboMatch.SetFocus
- End Sub
I've also tried "" rather than IsNull/= Null, and tried all of this with and without the DoCmd.Save, and even tested it out with On Dirty. The value in txtPropIndex will not ever go away.
Help? Please...?