This seems relatively simple, but I'm not sure what is causing Access to act up.
I get the Error 3070 on "UserName" when I run this code:
I've double checked the table, and it does indeed have a field named 'UserName'. Both fields in both tables are Short Text, and both field names are correct. I've compacted and repaired it, but no luck. I've also set a combo box record source to the RequestTemp table's field list, and the 'UserName' field shows up on the list.
Thoughts?
Problem solved: typo; used the tdf for both recordsets! Dumb mistake...
I get the Error 3070 on "UserName" when I run this code:
Code:
Public Sub UpdateUserID()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim tdf2 As DAO.TableDef
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db = CurrentDb
Set tdf = db.TableDefs("Users")
Set tdf2 = db.TableDefs("RequestTemp")
Set rst = tdf.OpenRecordset(dbOpenSnapshot, dbSeeChanges)
Set rst2 = tdf.OpenRecordset(dbOpenDynaset, dbSeeChanges)
With rst2
Do Until .EOF
If .EOF Then Exit Sub
.FindFirst "[UserName] =" & rst!EnvironName
If .NoMatch Then
GoTo NextRecord
End If
.Edit
!UserID = rst!UserID
.Update
NextRecord:
.MoveNext
Loop
End With
End Sub
I've double checked the table, and it does indeed have a field named 'UserName'. Both fields in both tables are Short Text, and both field names are correct. I've compacted and repaired it, but no luck. I've also set a combo box record source to the RequestTemp table's field list, and the 'UserName' field shows up on the list.
Thoughts?
Problem solved: typo; used the tdf for both recordsets! Dumb mistake...