• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

Error: "The action cannot be carried out while processing a form event."

I am getting the error on this line:
           DoCmd.Close acForm, "FRM_New_Student_Detail", acSaveNo

What event is processing that is preventing it from closing?

A screenshot is attached as well.

Private Sub Form_Activate()
           
    Dim strCurrentID As String
    Dim strCurrentLast As String
    
    STU_ID = Forms![FRM_Main_Login_Students]![stuIDTextBox].Value
    LastName = Forms![FRM_Main_Login_Students]![lastNameTextBox].Value
    
    
    'Search for inputed values in dbo_STUDENT_DIM table.
    strCurrentID = Nz(DLookup("STU_ID", "dbo_STUDENT_DIM", "[STU_ID]=" & "[STU_ID]"))
    strCurrentLast = Nz(DLookup("LastName", "dbo_STUDENT_DIM", "STU_LAST_NAME='" & LastName & "' and  [STU_ID]= " & STU_ID))
        
    'If input is not found in TBL_Students, give error message and return to main login screen
    If strCurrentID = -1 Or strCurrentLast = "" Then
        If MsgBox("The information you entered did not match any IWU student records.  Please try again.", vbOKOnly, "Invalid Entry") = vbOK Then
           DoCmd.Close acForm, "FRM_New_Student_Detail", acSaveNo
           DoCmd.OpenForm "FRM_Main_Login_Students", acNormal
           Exit Sub
        End If
    'If input is found, add all user data into the fields of TBL_Students
    Else
         FirstName = STU_FIRST_NAME
         Middle = STU_MIDDLE_NAME
         LastName = STU_LAST_NAME
         Campus_Box = STU_CAMPUS_ADDR1
         Phone = STU_CELL_PHONE
         Email = STU_EMAIL
         Address = STU_ADDR1
         City = STU_CITY
         State_Abbreviation = STU_STATE
         Zip = STU_ZIP
    End If
End Sub

Open in new window

run-time-error-2585.gif
0
mkelly2384
Asked:
mkelly2384
  • 7
  • 5
  • 2
1 Solution
 
tbsgadiCommented:
Try without the acSaveNo

Gary
0
 
Rey Obrero (Capricorn1)Commented:
do not use the forms Activate event to close the form

remove this line on that event
    DoCmd.Close acForm, "FRM_New_Student_Detail", acSaveNo
0
 
tbsgadiCommented:
Which form are you running this code from?
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Rey Obrero (Capricorn1)Commented:
try closing the form    "FRM_New_Student_Detail",  in the form "FRM_Main_Login_Students" module
 
0
 
mkelly2384Author Commented:
Ok, I removed the  DoCmd.Close line and added it to the activate event of "FRM_Main_Login_Students", but it gave me the same error message for the same line, only in the other form.
0
 
Rey Obrero (Capricorn1)Commented:

can we see your db. upload a copy.
0
 
mkelly2384Author Commented:
Here it is.  It connects to a SQL server at my location, so you may get extra error messages.
CLCL-Login-Database.mdb
0
 
Rey Obrero (Capricorn1)Commented:
move the codes in the Activate event to the Open event
Private Sub Form_Open(cancel as integer)
           
    Dim strCurrentID As String
    Dim strCurrentLast As String
    
    STU_ID = Forms![FRM_Main_Login_Students]![stuIDTextBox].Value
    LastName = Forms![FRM_Main_Login_Students]![lastNameTextBox].Value
    
    
    'Search for inputed values in dbo_STUDENT_DIM table.
    strCurrentID = Nz(DLookup("STU_ID", "dbo_STUDENT_DIM", "[STU_ID]=" & "[STU_ID]"))
    strCurrentLast = Nz(DLookup("LastName", "dbo_STUDENT_DIM", "STU_LAST_NAME='" & LastName & "' and  [STU_ID]= " & STU_ID))
        
    'If input is not found in TBL_Students, give error message and return to main login screen
    If strCurrentID = -1 Or strCurrentLast = "" Then
        If MsgBox("The information you entered did not match any IWU student records.  Please try again.", vbOKOnly, "Invalid Entry") = vbOK Then
      '     DoCmd.Close acForm, "FRM_New_Student_Detail", acSaveNo
           '*****
           'this will Cancel the opening of the form

           Cancel=true
           
           DoCmd.OpenForm "FRM_Main_Login_Students", acNormal
           Exit Sub
        End If
    'If input is found, add all user data into the fields of TBL_Students
    Else
         FirstName = STU_FIRST_NAME
         Middle = STU_MIDDLE_NAME
         LastName = STU_LAST_NAME
         Campus_Box = STU_CAMPUS_ADDR1
         Phone = STU_CELL_PHONE
         Email = STU_EMAIL
         Address = STU_ADDR1
         City = STU_CITY
         State_Abbreviation = STU_STATE
         Zip = STU_ZIP
    End If
End Sub

Open in new window

0
 
mkelly2384Author Commented:
When I moved the code from the activate event to the open event and test it, I get this error:
"You can't assign a value to this object."

It is referring to this line in the open event of FRM_New_Student_Detail:
    STU_ID = Forms![FRM_Main_Login_Students]![stuIDTextBox].Value
run-time-error.gif
0
 
Rey Obrero (Capricorn1)Commented:
mkelly2384,
create a table with the same structure as dbo_Student_DIM with this query

SELECT dbo_STUDENT_DIM.* INTO dbo_Student_DIM1
FROM dbo_STUDENT_DIM

then upload it.
0
 
mkelly2384Author Commented:
I put sample data in the dbo_STUDENT_DIM table.  I was just having problems if the user typed in wrong data (like an ID number and Last Name that didn't match any record), but now I am having that error regardless.  Let me know what you think.  I feel like I've taken two steps back today on this thing.  Thanks!
CLCL-Login-Database--2002-2003-.mdb
0
 
mkelly2384Author Commented:
I'm getting a "you can't go to the specified record" message when I open this file that I uploaded.  Good grief--this whole thing is falling apart!
0
 
mkelly2384Author Commented:
I FINALLY got it figured out.  The problem was the FRM_First_Time_Message was opening the FRM_New_Student_Details when I didn't want it to.  So I moved all of the code from FRM_New_Student_Details to FRM_First_Time_Message and it worked.  Thanks for looking at it, everyone.  Sorry it was such an issue.
0
 
mkelly2384Author Commented:
I did not add this question to the Knowledge Base, because I didn't feel like it would help anyone else.
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now