This is about your code.
You have code like:
Code:
<snip>
If chkcgmp.Value = "-1" Then
strAreaOfOper = lblchkcgmp.Caption
End If
If chkSAP.Value = "-1" Then
If strAreaOfOper = "" Then
strAreaOfOper = lblSAP.Caption
Else
strAreaOfOper = strAreaOfOper & ", " & lblSAP.Caption
End If
End If
<snip>
"chkcgmp" and "chkSAP" (two of many) are check box controls bound to a Yes/No type field. This is a number (a zero or a minus 1). The only values that the field can be is zero (0) or minus 1 (-1).
Microsoft has declared two constants: FALSE is equal to zero. TRUE is equal to -1.
Mathematically, FALSE = 0 and TRUE = Not FALSE. This means that TRUE can be any number other than zero!
Test it out. Add a text box control to a form and bind it to a number type field (Integer, Long Integer, Single or Double). Now add a check box control to a form and bind it to the same field as the text box.
Set the value for the text box to zero; the check box control will show FALSE.
Set the value for the text box to 100; the check box control will show TRUE.
You have a text string being compared to a number!!
If "chkcgmp" value is equal to TRUE (-1) and the test is
Code:
If chkcgmp = "-1" then
the result will ALWAYS return FALSE because a number is NEVER equal to a string!
It is the same as asking "Is -1 equal to "Microsoft"? Obviously the answer is and will forever be NO.
The point being, you should use the defined constants TRUE or FALSE instead of 0, -1, "0" or "-1".
Code:
<snip>
If chkcgmp.Value = TRUE Then
strAreaOfOper = lblchkcgmp.Caption
End If
If chkSAP.Value = TRUE Then
If strAreaOfOper = "" Then
strAreaOfOper = lblSAP.Caption
Else
strAreaOfOper = strAreaOfOper & ", " & lblSAP.Caption
End If
End If
<snip>
".Value" is not needed because "Value" is the default property. Doesn't hurt to use it, but it is a waste of time and typing.
Also, using the "Me." keyword makes the code clearer: Me.chkcgmp indicates a control on the form. "chkcgmp" can be a control or a variable defined in the code.
Last rant:
Instead of this code
Code:
<snip>
CurrentDb.Execute " UPDATE EmployeeI " _
& " SET [AreaOfOper] = '" & strAreaOfOper & "' " _
& "WHERE [EMployee_ID] = '" & Me.metxtemp & "'"
I use
Code:
<snip>
sSQL = "UPDATE EmployeeI SET [AreaOfOper] = '" & strAreaOfOper & "'"
sSQL = sSQL & " WHERE [EMployee_ID] = '" & Me.metxtemp & "';"
Debug.Print sSQL
CurrentDb.Execute sSQL, dbFailOnError
because I can check if the SQL syntax is correct and I can see what the variable values are.