mkelly2384
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.
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
run-time-error-2585.gif
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
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
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.
ASKER
Here it is. It connects to a SQL server at my location, so you may get extra error messages.
CLCL-Login-Database.mdb
CLCL-Login-Database.mdb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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_Stud ents]![stu IDTextBox] .Value
run-time-error.gif
"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_Stud
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.
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.
ASKER
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
CLCL-Login-Database--2002-2003-.mdb
ASKER
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!
ASKER
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.
ASKER
I did not add this question to the Knowledge Base, because I didn't feel like it would help anyone else.
Gary