I am opening a form to allow the user to change names contained in a child table (multiple records)
and having the user enter the old name and the new name
Code below fails. NamePhone in the table projects - says its not defined in context - and yet that is the name of the field in the table projects. I am assuming its just something I have missed.
1.
Line 7 fails, NamePhone has no value. This is the Projects table - I am trying to update records field NAmePhone with NewName when they match oldname
Projectid projectname cost NamePhone
1 Spinning $3.34 JustKeys
2 Dancing $4.35 SamBird
3 Running $2.3 JustKeys
4 Jogging $3.99 AnsKay
and having the user enter the old name and the new name
Code below fails. NamePhone in the table projects - says its not defined in context - and yet that is the name of the field in the table projects. I am assuming its just something I have missed.
1.
Code:
Private Sub cmdNewName_Click()
2. Dim rsProjects As ADODB.Recordset
3. Dim strSQL As String
4. Set conDatabase = CurrentProject.Connection
5. strSQL = "SELECT * FROM Projects WHERE NamePhone =" & oldname
6. Set rsProjects = New ADODB.Recordset
7. rsProjects.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
8. With rsProjects
9. Do While Not .EOF
10. !NamePhone = Newname
11. .Update
12. .MoveNext
13. Loop
14. End With
15. rsProjects.Close
16. conDatabase.Close
17. Set rsProjects = Nothing
Line 7 fails, NamePhone has no value. This is the Projects table - I am trying to update records field NAmePhone with NewName when they match oldname
Projectid projectname cost NamePhone
1 Spinning $3.34 JustKeys
2 Dancing $4.35 SamBird
3 Running $2.3 JustKeys
4 Jogging $3.99 AnsKay