Link to home
Start Free TrialLog in
Avatar of mkelly2384
mkelly2384Flag for United States of America

asked on

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
Avatar of tbsgadi
tbsgadi
Flag of Israel image

Try without the acSaveNo

Gary
Avatar of Rey Obrero (Capricorn1)
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
Which form are you running this code from?
try closing the form    "FRM_New_Student_Detail",  in the form "FRM_Main_Login_Students" module
 
Avatar of mkelly2384

ASKER

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.

can we see your db. upload a copy.
Here it is.  It connects to a SQL server at my location, so you may get extra error messages.
CLCL-Login-Database.mdb
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
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
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!
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.
I did not add this question to the Knowledge Base, because I didn't feel like it would help anyone else.