B
Bre-x
I have a form (SW) with one single object, a text box (EMP).
I get an error: This action cannt be carried out while processing a form
event
What i want is that when the user enter his ID, then press the "Enter" key,
close the form and open another.
Thanks,
Bre-x
This is my code:
Private Sub EMP_Enter()
On Error GoTo Err_EMP_Enter
Dim sqlstring As String
If IsNull(Me.EMP) = True Then
Exit Sub
End If
sqlstring = "SELECT Count(*) AS CC FROM EMP WHERE EMP_NUM=" & Me.EMP
CurrentDb.QueryDefs("MS").SQL = sqlstring
If DLookup("[CC]", "MS") = 0 Then
Responce = MsgBox("WRONG EMP ID ", vbCritical, " MYCOMPANY")
Me.EMP = Null
Me.EMP.SetFocus
Exit Sub
Else
'SETUP MAIN FORM
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE FMAIN SET EMP = " & Me.EMP
DoCmd.SetWarnings True
DoCmd.OpenForm "MAIN"
DoCmd.Close acForm, "SW"
End If
Exit_EMP_Enter:
Exit Sub
Err_EMP_Enter:
MsgBox Err.Description & " " & Err.Number
Resume Exit_EMP_Enter
End Sub
I get an error: This action cannt be carried out while processing a form
event
What i want is that when the user enter his ID, then press the "Enter" key,
close the form and open another.
Thanks,
Bre-x
This is my code:
Private Sub EMP_Enter()
On Error GoTo Err_EMP_Enter
Dim sqlstring As String
If IsNull(Me.EMP) = True Then
Exit Sub
End If
sqlstring = "SELECT Count(*) AS CC FROM EMP WHERE EMP_NUM=" & Me.EMP
CurrentDb.QueryDefs("MS").SQL = sqlstring
If DLookup("[CC]", "MS") = 0 Then
Responce = MsgBox("WRONG EMP ID ", vbCritical, " MYCOMPANY")
Me.EMP = Null
Me.EMP.SetFocus
Exit Sub
Else
'SETUP MAIN FORM
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE FMAIN SET EMP = " & Me.EMP
DoCmd.SetWarnings True
DoCmd.OpenForm "MAIN"
DoCmd.Close acForm, "SW"
End If
Exit_EMP_Enter:
Exit Sub
Err_EMP_Enter:
MsgBox Err.Description & " " & Err.Number
Resume Exit_EMP_Enter
End Sub