I get this error on my form:
The following runtime error occured:
Number: 3265
Description: Item not found in this collection
Object Type: Form
Procedure: No_LostFocus
Object: frmMain
I changed this code: (which works perfectly)
Code:
Private Sub No_LostFocus()
Dim t_cbo_name
Dim strsql AS String
Dim db AS database
Dim rec AS Recordset
Set db = currentDB
Set rec = db.OpenRecordset("tbl_initial_seeder")
Do until rec.EOF
with rec
If Trim(!login_id) = Trim(Me.txt_winusername) Then
t_name = ![id]
t_cbo_name = !p
If IsNull(Me.Data_Input_by_name_box) Then
Me.Data_Input_by_name_box = t_cbo_name
Else
End If
Else
End If
.MoveNext
End With
Loop
Set rec = Nothing
Me.WinUserName_box = txt_winusername
Me.date_updated = Now()
Debug.Print t_name, Me.txt_winusername, t_cbo_name
Do.Cmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_no_LostFocus()
Exit Sub
To this code which is what produces the error I posted above
Code:
Private Sub No_LostFocus()
Dim t_cbo_name
Dim strsql AS String
Dim db AS database
Dim rec AS Recordset
Set db = currentDB
Set rec = db.OpenRecordset("tbl_j")
Do until rec.EOF
with rec
If Trim(!login_id) = Trim(Me.txt_winusername) Then
t_name = ![id]
t_cbo_name = !Name
If IsNull(Me.Record_Input_By) Then
Me.Data_Input_by_name_box = t_cbo_name
Else
End If
Else
End If
.MoveNext
End With
Loop
Set rec = Nothing
Me.WinUserName_box = txt_winusername
Me.date_updated = Now()
Debug.Print t_name, Me.txt_winusername, t_cbo_name
Do.Cmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_no_LostFocus()
Exit Sub
I am wanting to change the db.OpenRecordset to another table (table_j)
The t_name = ![id] ---- I am assuming this is fine, since both tables have "id"
the t_cbo_name = !p --- I am trying to change that to name, because I want it to display the name in the table I am trying to change over to