The problem is that I have a table called student, and in it there is a city field...
in the student form I want to get the student's city from a combo box which gets it's information from the city table....
now if the student is from a city doesn't already exists in the city table... I want to add the new city to the city table when I add the student, so that I'll not have to add the city to city table by myself....
for this task I tried this code...
Private Sub cmb_City_LostFocus()
Dim found As Boolean
found = False
Dim RST As Recordset
Set RST = CurrentDb.OpenRecordset("City_T", dbOpenTable)
RST.MoveFirst
Do Until RST.EOF
If RST![City] = Me.cmb_City.Text Then
found = found Or True
Else
found = found Or True
End If
RST.MoveNext
Loop
RST.MoveLast
If Not found Then
RST.AddNew
RST![City] = Me.cmb_City.Text
RST.Update
End If
RST.Close
End Sub
and yet it's not working,
so I was wondering what is the problem!!!!
so can you please tell me how can I fix that!!!!
thx for your time....