I'm trying to automatically update a field in a table based on what has been inserted in another field. I have been successful in one table but not in another although I have been using the same code, and the same way. Here is the piece of code which is not working;
Expand|Select|Wrap|Line Numbers
- Dim rsLiability As DAO.Recordset
- Dim strSql As String
- strSql = "SELECT txtLiabilityCategory, txtLiabilityName FROM tblLiability;"
- Set rsLiability = DBEngine(0)(0).OpenRecordset(strSql, dbOpenDynaset)
- Do While Not rsLiability.EOF
- If rsLiability!txtLiabilityName = "Dhima/Mkopo wa Muda Mrefu(Zaidi ya mwaka mmoja)" And rsLiability!txtLiabilityCategory = "Madeni" Then
- rsLiability.Edit
- rsLiability!txtLiabilityCategory = "Non-current"
- rsLiability.Update
- ElseIf rsLiability!txtLiabilityName = "Dhima/Mkopo wa Muda Mfupi(Chini ya mwaka mmoja)" And rsLiability!txtLiabilityCategory = "Madeni" Then
- rsLiability.Edit
- rsLiability!txtLiabilityCategory = "Current"
- rsLiability.Update
- End If
- rsLiability.MoveNext
- Loop
- 'Closing and resetting the recordset
- rsLiability.Close
- Set rsLiability = Nothing
Any idea of why it doesn't work or other way around to do it better?