Originally Posted by
aytee111
I'm not sure why the TeamID has a value when you open the Add Assessor form. It is the value on the first record of the table, it must be a timing thing. In the OnLoad event of the form change the first line to read - If Me.Filter="" Then
OK, I've done this and it's still happening, I checked the filter when I selected Add Assessor, and it still has an "AssessorID=11" in the filter, so I suspect that is the problem?
Originally Posted by
aytee111
That's on the assessor record, not assessment! OK, in the AfterUpdate: you don't need the HoldLoginID, you will not lose it (like on the other forms) so you can get rid of that and just reference the one on the form. It should be a String variable anyway. Also, get rid of the "Me.Undo" - that will wipe out everything the user has entered, very irritating! In the first part just delete the line, in the second rather set the login to blank..
Ok, I think this is what you mean? If so, it highlights what I have placed in italics.
Code:
Private Sub LoginID_AfterUpdate()
If IsNull(DLookup("LoginID", "tblAssessor", "LoginID=" & Me!LoginID)) Then
Else
Dim Msg, Style, Title, Response
Msg = "This User ID has already been entered onto the system. Please check you have entered the correct ID and the assessor is not already in the system. Do you want to view the record for the assessor with this ID?"
Style = vbYesNo
Title = "ID already exists!"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Me.Undo
Me.Filter = "LoginID=" & LoginID
Me.FilterOn = True
Me.Requery
Else
LoginID = ""
LoginID.SetFocus
End If
End If
End Sub
Originally Posted by
aytee111
Is it a required field? I would assume so, if you want to add any user security later. I hope at some time you are going to clean up your table field definitions, 255 lengths for text field shows lack of knowledge of what the fields are actually going to contain. It makes the processing slower and more inefficient and the database will grow in size much faster.
Yes, I could probably add restrictions like that, I didn't realise it made such a difference. The user security wouldn't use this userID - I have used the term UserID in both places, as it is the same type of ID (what is used to log onto the system), but the LoginID for the Assessor will not be used to log onto the system and those in tblUser will not be in the Assessor table (unless in very rare cases, but the tables aren't linked, so this shouldn't matter.
Originally Posted by
aytee111
I don't know what "doesn't seem to work" means. It works for me. You have a problem going to the Behaviours form when adding a new assessment, you must do the same as your other forms - filter when it exists and new record when it doesn't.
When I select the add a new assessment button, it highlights the following code in the final Else section and "Compile Error: Duplicate declaration in scope" message box appeared, does this not happen to you?