Stumped on another issue in Access 2003 (file format Access 2000) where code does not seem to do what it's supposed to based on other topics I have read.
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:
The form is Single Form view and bound to the new table, tblImportedFrom AAPList(2). cboMatch is an unbound combobox and gets its row source from the main table, tblDCCPropertie s. txtPropIndex shows the value of PropIndex, the foreign key in the new table, which (after being matched) relates it to the main table.
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:
The second bit of code is working according to plan, as far as I can tell. I hope it isn't interfering with the problem code.
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...?
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:
Code:
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:
Code:
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...?
Comment