Paul Cooke
Registered User.
- Local time
- Today, 23:43
- Joined
- Oct 12, 2001
- Messages
- 288
Hi guys - Could someone please advise me why my form is not closing please -I am getting a Run-time Error 2585 "This action can't be carried out whilst processing a form or a report"
The process I am using is
I open a form called "Select" select a name from the listbox (which is populated from a table called 'Patients' using a Select Qry) and click in an option group to open the form "Treatment"
The "Treatment" Form has 2 hidden controls TreatmentID & PatientID. The TreatmentID is the PK of the Treatment table but the PatientID is populated from the listbox on the form "Select" depending on what name is chosen there.
Once the Treatment form is opened all the controls are diasbled (by default) apart from the first one cboName. If the user does not enter anything in here and tabs out of it the next control cboDetails enables and has the focus. If the user tries to leave this control empty the Lostfocus event triggers as shown .....
The code errors out if the user opts to cancel the data entry (VbYes) and highlights the line
If I mark out this line the code runs fine but obviusley the Treatment form does not close. I have read loads on the net regarding this issue and thinnk it is because something is 'running' in the background but for the life of me I do not know what it is or how to stop it !!
Any advice will be gratefully recieved
Many thanks
Paul
(sorry for the lengthy post but I wanted to try annd give a full picture of the problem!)
The process I am using is
I open a form called "Select" select a name from the listbox (which is populated from a table called 'Patients' using a Select Qry) and click in an option group to open the form "Treatment"
The "Treatment" Form has 2 hidden controls TreatmentID & PatientID. The TreatmentID is the PK of the Treatment table but the PatientID is populated from the listbox on the form "Select" depending on what name is chosen there.
Once the Treatment form is opened all the controls are diasbled (by default) apart from the first one cboName. If the user does not enter anything in here and tabs out of it the next control cboDetails enables and has the focus. If the user tries to leave this control empty the Lostfocus event triggers as shown .....
Code:
Private Sub cboProductonEventTitle_LostFocus()
'Checks to see if a name has been entered in the Name control and details control if both are empty prompts user to try again or cancel the entry
If IsNull(Me.cboProductonEventTitle) = True Then
Beep
If bolDoExit = False Then
MsgResponse = MsgBox("As You have not entered a Production \ Employer Name or a Production \ Event Title, you can not continue entering details on this database form." & vbCrLf & vbCrLf & _
"If The Patient is with you, please complete a paper treatment form, ensuring you get full details of who they work for, if applicable" _
& vbCrLf & vbCrLf & "Do You want to cancel this form?", vbQuestion + vbYesNo, "Cancel Data Entry")
If MsgResponse = vbNo Then
MsgBox "Please enter either a Production \ Employer Name" & vbCrLf & "or a Production \ Event Title to continue", vbInformation + vbOKOnly, "Continue"
Else
If MsgResponse = vbYes Then
Me.Undo
If Me.Dirty = True Then
Me.Dirty = False
End If
DoEvents
DoCmd.OpenForm "Navigation"
DoCmd.Close acForm, "NewTreatment"
bolDoExit = True
End If
End If
End If
End If
End Sub
The code errors out if the user opts to cancel the data entry (VbYes) and highlights the line
Code:
DoCmd.Close acForm, "Treatment"
If I mark out this line the code runs fine but obviusley the Treatment form does not close. I have read loads on the net regarding this issue and thinnk it is because something is 'running' in the background but for the life of me I do not know what it is or how to stop it !!
Any advice will be gratefully recieved
Many thanks
Paul
(sorry for the lengthy post but I wanted to try annd give a full picture of the problem!)