Yes I have a very good idea as to why it's saying that LNAME is undefined: because it's not
It seems that you are running a query named 'TeacherFN', and now you're trying to access the data from that query. But, the data columns retrieved by that query (Lname and Fname) are not just going to magically appear as variables in your cfm page. So, data can be accessed from a query in one of two ways:
1) You can use the columns of a query in a cfoutput query or cfloop query. By doing it this way, the data columns from the query will be available via the "query" scope:
<!--- In both these examples, the 'TeacherFN' query gets loaded into
the query scope, so now the Lname and Fname data columns are
available as variables --->
<!--- Same thing as above --->
However, the catch to this is that both of these tags will "loop" over the query. That is in your case, if 'TeacherFN' returns more than one record, your code is going to be generating more than one INSERT/UPDATE/DELETE statement; one for each row returned by 'TeacherFN'. But, it looks like the 'TeacherFN' query is only supposed to return one row, so I recommend using the next method.
2) You can access the data returned by a query directly by retrieving them in the form: #queryName.columnName#. So, 'Lname' and 'Fname' from this query are available in your cfm page as #TeacherFN.Lname# and #TeacherFN.Fname#.
Your resulting code (with a bit of formatting) will look like this:
<cfquery name="TeacherFN" datasource="AITE_Test_System">
SELECT Lname, Fname
WHERE AD_Username = '#FORM.TeacherAD_Username#'
<cfquery name="ClassEdit" datasource="AITE_Test_System">
<cfif #FORM.EditMode# IS "AddClass">
INSERT INTO dbo.[Classes] (
) VALUES (
<cfelseif #FORM.EditMode# IS "EditClass">
<!--- Apparently your update statement is incomplete... --->
<cfelseif #FORM.EditMode# IS "DeleteClass">
Fname = '#TeacherFN.Fname#'
AND Lname = '#TeacherFN.Lname#'
AND Teacher_AD_Username = '#FORM.TeacherAD_Username#'
One last note: It is always good to retrieve the data returned by queries by putting it in the queryName.columnName form, even when getting the data via a cfoutput query or cfloop query. This helps tremendously in code readability, because you know that a variable is coming from query data and is not just a variable defined elsewhere. Ex:
Hope that all helps!