I have a simple form that uses a Main table for customers ‘TblCustomers’ that uses a sub table ‘TblCustCity’. Tabel Cust City has two Fields ‘ID” and “City_Town’.
I have a combo box that I can pick the town from, and can also add towns. With an ‘On Not in List’ event.:
Private Sub City_Town_NotInList(NewData As String, Response As Integer)
Dim TmpQuestion As String 'Temporary storage for the question
Dim TempCity As String 'Temporary Storage for the City data
'Get confirmation that this is not just a spelling error.
TmpQuestion = "Add '" & NewData & "' as a new City/Town?" ' store the question in TmpQuestion
If MsgBox(TmpQuestion, vbYesNo + vbDefaultButton2 + vbQuestion, "City/Town Not listed") = vbYes Then
'Store the new city name and table etc into TempCity
TempCity = "INSERT INTO TblCustCity(City_Town) VALUES ('" & NewData & "');"
DBEngine(0)(0).Execute TempCity, dbFailOnError
Response = acDataErrAdded
End If
End Sub
The adding of a new town City works ok but if I already have a town city in record and try to change it then I lose the old town /city and it’s replaced with a number.
The Control Source is:
City_Town
The Row source is:
SELECT DISTINCT TblCustCity.ID, TblCustCity.City_Town
FROM TblCustCity
ORDER BY TblCustCity.City_Town;
Limit to list is yes and Allow value list edits is No.
Can anyone explain why my data changes and how to correct this.
Example
I am in one customer record and his Town is Manchester. I decide to change this to Liverpool, Liverpool not being in the list so the ‘On Not in List’ event kicks in.
My new City Liverpool is added but when I look back Manchester has gone and is replaced with its ID number.
I have a combo box that I can pick the town from, and can also add towns. With an ‘On Not in List’ event.:
Private Sub City_Town_NotInList(NewData As String, Response As Integer)
Dim TmpQuestion As String 'Temporary storage for the question
Dim TempCity As String 'Temporary Storage for the City data
'Get confirmation that this is not just a spelling error.
TmpQuestion = "Add '" & NewData & "' as a new City/Town?" ' store the question in TmpQuestion
If MsgBox(TmpQuestion, vbYesNo + vbDefaultButton2 + vbQuestion, "City/Town Not listed") = vbYes Then
'Store the new city name and table etc into TempCity
TempCity = "INSERT INTO TblCustCity(City_Town) VALUES ('" & NewData & "');"
DBEngine(0)(0).Execute TempCity, dbFailOnError
Response = acDataErrAdded
End If
End Sub
The adding of a new town City works ok but if I already have a town city in record and try to change it then I lose the old town /city and it’s replaced with a number.
The Control Source is:
City_Town
The Row source is:
SELECT DISTINCT TblCustCity.ID, TblCustCity.City_Town
FROM TblCustCity
ORDER BY TblCustCity.City_Town;
Limit to list is yes and Allow value list edits is No.
Can anyone explain why my data changes and how to correct this.
Example
I am in one customer record and his Town is Manchester. I decide to change this to Liverpool, Liverpool not being in the list so the ‘On Not in List’ event kicks in.
My new City Liverpool is added but when I look back Manchester has gone and is replaced with its ID number.