Randomblink
The Irreverent Reverend
- Local time
- Today, 11:58
- Joined
- Jul 23, 2001
- Messages
- 279
Here is the error I am getting on a Form I created.
This is the LostFocus event for a textbox on my Form.
This is the Public Function that is called from the LostFocus event above...
Can anyone tell me why I am not able to CLOSE the form while processing the LostFocus event? AND If I CAN'T do this, how do I close the form? Any ideas?
Thanks in advance...
Any help would be greatly appreciated...
Run-time error '2585'
This action can't be carried out while processing a form or report event.
This is the LostFocus event for a textbox on my Form.
Code:
Private Sub Proj_Title_LostFocus()
Dim strSQLCriteria As String, qry As String, Response As VbMsgBoxResult
On Error GoTo Err_ProjTitle
Select Case IsNull(Proj_Title)
Case True: GoSub Reminder
Case False: GoSub Link
End Select
Exit_ProjTitle:
Exit Sub
Reminder:
Response = MsgBox("You must enter a Project Title to Continue. Do you wish to continue?" & Chr(13) & Chr(10) & "Press YES if you wish to continue." & Chr(13) & Chr(10) & "Press NO if you wish to exit.", vbYesNo, "Project Title Required")
Select Case Response
Case vbYes: Proj_Title.SetFocus
Case vbNo: basicActions "Close Form", Me
End Select
Response = 0
Return
SureYouWantToLeave:
Response = MsgBox("If you leave now, no new Project will be created. Are you sure you wish to do this?" & Chr(13) & Chr(10) & "Press YES to exit." & Chr(13) & Chr(10) & "Press NO to enter a Project Title.", vbYesNo, "Exit Verification")
Select Case Response
Case vbYes: Exit Sub: basicActions "Close Form", Me
Case vbNo: Proj_Title.SetFocus
End Select
Response = 0
Return
Link:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.SetWarnings False
strSQLCriteria = "INSERT INTO [tbl_LINK_ProjectBasics-Employee] (Proj_ID, Empl_ID) VALUES (" & CInt(Me!Proj_ID) & ", " & CInt(UsrDtl("EmployeeID")) & ");"
DoCmd.RunSQL strSQLCriteria
pge_CityEmployees.Visible = True:
Proj_Bdgt.SetFocus: Proj_Title.Enabled = False
Return
Err_ProjTitle:
errMessage Err
Resume Exit_ProjTitle
End Sub
This is the Public Function that is called from the LostFocus event above...
Code:
Public Function basicActions(bscAction As String, Optional trgtForm As Form)
On Error GoTo Err_basicActions
Select Case bscAction
Case "Close Form": GoSub CloseForm
Case "Save Current Record": GoSub SaveCurRec
Case "Shut Down Application": GoSub CloseALL
Case "Add New Record": GoSub AddNewRec
End Select
Exit_basicActions:
Exit Function
AddNewRec:
DoCmd.GoToRecord , , acNewRec
Return
SaveCurRec:
DoCmd.RunCommand acCmdSaveRecord
Return
CloseALL:
Application.Quit acQuitSaveAll
Return
CloseForm:
DoCmd.Close acForm, trgtForm.Name, acSaveNo
If Forms.Count = 0 Then Application.Quit acQuitSaveAll
Return
Err_basicActions:
errMessage Err
Resume Exit_basicActions
End Function
Can anyone tell me why I am not able to CLOSE the form while processing the LostFocus event? AND If I CAN'T do this, how do I close the form? Any ideas?
Thanks in advance...
Any help would be greatly appreciated...