Set db = DBEngine.OpenDatabase("[URL="file://server/file.accdb"]\\server\file.accdb[/URL]")
Set rs = db.OpenRecordset("tblUser", dbOpenTable)
rs.MoveFirst
Do Until rs.EOF
If rs.Fields("Username") = NetworkUserName Then
If rs.Fields("User Role") = 5 Then 'AUDIT USER
Form_frmParent.cboUser.Enabled = True
Form_frmParent.subWork.LinkMasterFields = ""
Form_frmParent.subWork.LinkChildFields = ""
Else 'NORMAL USER
Form_frmParent.cboUser = rs.Fields("UserID")
Form_frmParent.cboUser.Enabled = False
Form_frmParent.subWork.LinkMasterFields = "cboUser"
Form_frmParent.subWork.LinkChildFields = "UserID"
End If
End If
rs.MoveNext
Loop
Private Sub Form_AfterDelConfirm(Status As Integer)
DoCmd.Save
End Sub
Private Sub Form_AfterUpdate()
DoCmd.Save
End Sub
Do Until rs.EOF If rs.Fields("Username") = NetworkUserName Then If rs.Fields("User Role") = 5 Then 'AUDIT USER Form_frmParent.cboUser.Enabled = True Form_frmParent.subWork.LinkMasterFields = "" Form_frmParent.subWork.LinkChildFields = ""
i think the problem lies in here:
when new record is added userid will be blank.Code:Do Until rs.EOF If rs.Fields("Username") = NetworkUserName Then If rs.Fields("User Role") = 5 Then 'AUDIT USER Form_frmParent.cboUser.Enabled = True Form_frmParent.subWork.LinkMasterFields = "" Form_frmParent.subWork.LinkChildFields = ""
Okay, got it and found first problem...
The not a valid Bookmark error is because you have corruption in tblWork. Look at the records for User ID 14 and you will see them. You need to remove those. Now, you could try Compact & Repair but that might not work so...
Export the Table out to Excel, remove the bad records and reimport.
Next suggestion...
Remove ALL the Form_frmParent and replace with Me because that will cause other issues. Note, that is not something you use regularly, as a matter of fact I use so sparingly I can count on my hands the amount of times I needed it.
Doing the above should fix your issues.