Is the field "Username" a text type field or numeric? If it is a text type field (you are storing text), there needs to be delimiters in the SQL string.
Code:
SQL = "Insert into Users (Username,SecurityLevel_FK) "
SQL = SQL & "Values ('" & Forms!SystManHome!NSfSystManHome.Form!tbNewUser & "'," ' <--single quotes in this line
SQL = SQL & DLookup("[ID]", "tblSecurityLevels", "[Level]='" & Forms!SystManHome!NSfSystManHome.Form!cbSecLevels & "'") & ")"
Expanded, it looks like:
SQL = SQL & "Values ( ' " & Forms!SystManHome!NSfSystManHome.Form!tbNewUser & " ' ,"
Also, it might be easier to create two variables to get the values and use the variables in the SQL.
Code:
Dim UN as String
Dim SL_FK as Long
UN = Forms!SystManHome!NSfSystManHome.Form!tbNewUser
SL_FK = [SIZE=2]DLookup("[ID]", "tblSecurityLevels", "[Level]='" & Forms!SystManHome!NSfSystManHome.Form!cbSecLevels & "'")
SQL = "Insert into Users (Username,SecurityLevel_FK) "
SQL = SQL & "Values ('" & UN & "', " & SL_FK & ")"
' Debug.Print SQL
Currentdb.Execute SQL, dbfailonerror
This makes it easier to check the values when single stepping through the code.
BTW, "SQL" is a reserved word in Access and shouldn't be used as an object name. Maybe use "strSQL" or "sSQL".
Edit: ranman256 is correct. You should be able to get the security level froim the combo box.
I missed that......