Discussion:
Run-time Error 2585: Unable to Close Form
(too old to reply)
Bre-x
2010-05-17 15:33:44 UTC
Permalink
Hi, I need some help here, no matter what I do I can not close the FS form.

On my FS For I have on single text box (tlogin) and I am using the Enter
event to
to some "systems checks" then launch the Main Form (FMAIN)



Private Sub tlogin_Enter()
On Error GoTo Err_Command_tlogin_Enter

If IsNull(Me.tlogin) = True Then
Exit Sub
End If

var_user = Me.tlogin

'CHECK IF EMP IS ON TC
If emp_is_tc(var_user) = False Then

'EMP IS NOT ON TC
'CHECK IF EMP IS ON DBA
If emp_is_dba(var_user) = False Then
'EMP IS NOT ON DBA, EXIT SUB
Responce = MsgBox("Unable to Find Emp ID. Contact Foreman. ",
vbCritical, " UMCORP")
Exit Sub
End If

'INSERT EMP INTO TIME CLOCK
emp_new (var_user)
End If


'CHECK IF EMP IS IN (SHIFT_START)
If shift_in(var_user) = False Then
shift_start (var_user)
End If

'ALL SYSTEMS CHECKED!!! OPEN MAIN WINDOW
Me.tlogin = Null

DoCmd.OpenForm "FMAIN"
DoCmd.Close acForm, "FS"

Exit_Command_tlogin_Enter:
Exit Sub
Err_Command_tlogin_Enter:
MsgBox Err.Description & " " & Err.Number
Resume Exit_Command_tlogin_Enter
End Sub
Dirk Goldgar
2010-05-17 16:57:09 UTC
Permalink
Post by Bre-x
Hi, I need some help here, no matter what I do I can not close the FS form.
On my FS For I have on single text box (tlogin) and I am using the Enter
event to
to some "systems checks" then launch the Main Form (FMAIN)
Private Sub tlogin_Enter()
On Error GoTo Err_Command_tlogin_Enter
If IsNull(Me.tlogin) = True Then
Exit Sub
End If
var_user = Me.tlogin
'CHECK IF EMP IS ON TC
If emp_is_tc(var_user) = False Then
'EMP IS NOT ON TC
'CHECK IF EMP IS ON DBA
If emp_is_dba(var_user) = False Then
'EMP IS NOT ON DBA, EXIT SUB
Responce = MsgBox("Unable to Find Emp ID. Contact Foreman. ",
vbCritical, " UMCORP")
Exit Sub
End If
'INSERT EMP INTO TIME CLOCK
emp_new (var_user)
End If
'CHECK IF EMP IS IN (SHIFT_START)
If shift_in(var_user) = False Then
shift_start (var_user)
End If
'ALL SYSTEMS CHECKED!!! OPEN MAIN WINDOW
Me.tlogin = Null
DoCmd.OpenForm "FMAIN"
DoCmd.Close acForm, "FS"
Exit Sub
MsgBox Err.Description & " " & Err.Number
Resume Exit_Command_tlogin_Enter
End Sub
When are you thinking that the Enter event fires? It's not when the user
presses the Enter key, if that's what you were thinking. I suspect that you
ought to be using the text box's AfterUpdate event, but maybe there's some
logic behind this that I'm not understanding.
--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
Bre-x
2010-05-17 17:29:49 UTC
Permalink
Thank you!!!

I change my code to the AfterUpdate event and everything is working fine!!!!
Post by Dirk Goldgar
Post by Bre-x
Hi, I need some help here, no matter what I do I can not close the FS form.
On my FS For I have on single text box (tlogin) and I am using the Enter
event to
to some "systems checks" then launch the Main Form (FMAIN)
Private Sub tlogin_Enter()
On Error GoTo Err_Command_tlogin_Enter
If IsNull(Me.tlogin) = True Then
Exit Sub
End If
var_user = Me.tlogin
'CHECK IF EMP IS ON TC
If emp_is_tc(var_user) = False Then
'EMP IS NOT ON TC
'CHECK IF EMP IS ON DBA
If emp_is_dba(var_user) = False Then
'EMP IS NOT ON DBA, EXIT SUB
Responce = MsgBox("Unable to Find Emp ID. Contact Foreman. ",
vbCritical, " UMCORP")
Exit Sub
End If
'INSERT EMP INTO TIME CLOCK
emp_new (var_user)
End If
'CHECK IF EMP IS IN (SHIFT_START)
If shift_in(var_user) = False Then
shift_start (var_user)
End If
'ALL SYSTEMS CHECKED!!! OPEN MAIN WINDOW
Me.tlogin = Null
DoCmd.OpenForm "FMAIN"
DoCmd.Close acForm, "FS"
Exit Sub
MsgBox Err.Description & " " & Err.Number
Resume Exit_Command_tlogin_Enter
End Sub
When are you thinking that the Enter event fires? It's not when the user
presses the Enter key, if that's what you were thinking. I suspect that
you ought to be using the text box's AfterUpdate event, but maybe there's
some logic behind this that I'm not understanding.
--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html
(please reply to the newsgroup)
Loading...