He stated that I am working with two forms when i am only working with one form. Also, he stated that the forms closes as such the data is lost which is not true as the two events that I have used are on the form when it is active.
Here is your code without using code tags so that I can show colour:
Private Sub Command1_Click()
Dim ID As Integer
Dim level As Integer
Dim tempname As String
If IsNull(Me.txtlevel1) Or (Me.txtlevel1) = 2 Then
DoCmd.Close
DoCmd.OpenForm "login"
Else
<-- so if txtlevel1 is OK, do the DLookups and assign them to (undeclared?) variables "levels" and "user"
level = DLookup("ID", "securitylevel", "[securityID]='" & Me.txtlevel1.Value & "'")
user = DLookup("[username]", "users", "[userlogin]='" & Me.txtuser1.Value & "'")
DoCmd.Close
<-- now close this form because simply "close" closes the active object
EDIT- come to think of it, I cannot see the rest of this running anyway once you've invoked the close method of this form. It should be the last thing done on this form.
DoCmd.OpenForm "Employee info"
<--now open another form, even though you say there is only one involved
Forms![employee info]![txtemplevel] = level
<--now try make these controls equal the values for user and level, which are no longer in scope because you just closed the form they were on
Forms![employee info]![txtlogname] = user
Forms![employee info]![Username] = user
End If
End Sub
If you have declared
user and
level as variables somewhere else and their scope is either global or they are at the module level then you need to explain that, otherwise it looks like it is your problem. "the two events that I have used are on the form when it is active" means nothing if the scope of the variables is limited to the form you closed, or a sub that terminates even if the form remains open. You need to clear up where those variables are declared.