473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant get a criteria form to close

Any help with this would be greatly appreciated, as cannot work out how
to resolve.

I have a report called "3_Strikes" . In its 'On open' event is command
to also open a criteria form popup form called, "3_Strikes_Sear ch".
The purpose of the form is to allow input of data to filter the results
of the report, (In this case mail-merged letters).

The issue I have is that when I open the report via a command button,
the "3_Strikes_Sear ch" form pops up. However if at this stage I decide
not to run the report, I cant close the pop-up form without various
error messages.

I imagine this is because the Open Report event has already taken place
in the background.

The first error is when click on the close button is:
This action cant be carried out while processing a form or report
event.
When I click okay it then prompting for date via parameter query input
boxes.

I am not experienced enough to devise a solution by VBA. So a point in
the right direction would be really useful.
Thanks
Zack

May 3 '06 #1
4 2498
On 3 May 2006 03:54:15 -0700, zack wrote:
Any help with this would be greatly appreciated, as cannot work out how
to resolve.

I have a report called "3_Strikes" . In its 'On open' event is command
to also open a criteria form popup form called, "3_Strikes_Sear ch".
The purpose of the form is to allow input of data to filter the results
of the report, (In this case mail-merged letters).

The issue I have is that when I open the report via a command button,
the "3_Strikes_Sear ch" form pops up. However if at this stage I decide
not to run the report, I cant close the pop-up form without various
error messages.

I imagine this is because the Open Report event has already taken place
in the background.

The first error is when click on the close button is:
This action cant be carried out while processing a form or report
event.
When I click okay it then prompting for date via parameter query input
boxes.

I am not experienced enough to devise a solution by VBA. So a point in
the right direction would be really useful.
Thanks
Zack


Open the form from the Report's Open event, then check if it is still
open. If not, cancel the event (and the report).

If you have Access 2000 or newer:
Code the Report's Open event:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog

If Not CurrentProject. AllForms("3_Str ikes_Search").I sLoaded Then
MsgBox "Report has been cancelled"
Cancel = True
End If

If the Report has been opened from a code event (on a switchboard, for
example), closing the report will generate error 2501. Trap that error
in the switchboard event:

On Error GoTo Err_Handler
DoCmd.OpenRepor t "3_Strikes" , acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 3 '06 #2

fredg wrote:
On 3 May 2006 03:54:15 -0700, zack wrote:
Any help with this would be greatly appreciated, as cannot work out how
to resolve.

I have a report called "3_Strikes" . In its 'On open' event is command
to also open a criteria form popup form called, "3_Strikes_Sear ch".
The purpose of the form is to allow input of data to filter the results
of the report, (In this case mail-merged letters).

The issue I have is that when I open the report via a command button,
the "3_Strikes_Sear ch" form pops up. However if at this stage I decide
not to run the report, I cant close the pop-up form without various
error messages.

I imagine this is because the Open Report event has already taken place
in the background.

The first error is when click on the close button is:
This action cant be carried out while processing a form or report
event.
When I click okay it then prompting for date via parameter query input
boxes.

I am not experienced enough to devise a solution by VBA. So a point in
the right direction would be really useful.
Thanks
Zack


Open the form from the Report's Open event, then check if it is still
open. If not, cancel the event (and the report).

If you have Access 2000 or newer:
Code the Report's Open event:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog

If Not CurrentProject. AllForms("3_Str ikes_Search").I sLoaded Then
MsgBox "Report has been cancelled"
Cancel = True
End If

If the Report has been opened from a code event (on a switchboard, for
example), closing the report will generate error 2501. Trap that error
in the switchboard event:

On Error GoTo Err_Handler
DoCmd.OpenRepor t "3_Strikes" , acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Fred, Thank you for your response, this issue is that I have inherited
this database and so is still in Access 97. Could you help with a
conversion of the above code that would work in 97.
Many thanks
Zack

May 5 '06 #3
On 5 May 2006 02:40:23 -0700, zack wrote:
fredg wrote:
On 3 May 2006 03:54:15 -0700, zack wrote:
Any help with this would be greatly appreciated, as cannot work out how
to resolve.

I have a report called "3_Strikes" . In its 'On open' event is command
to also open a criteria form popup form called, "3_Strikes_Sear ch".
The purpose of the form is to allow input of data to filter the results
of the report, (In this case mail-merged letters).

The issue I have is that when I open the report via a command button,
the "3_Strikes_Sear ch" form pops up. However if at this stage I decide
not to run the report, I cant close the pop-up form without various
error messages.

I imagine this is because the Open Report event has already taken place
in the background.

The first error is when click on the close button is:
This action cant be carried out while processing a form or report
event.
When I click okay it then prompting for date via parameter query input
boxes.

I am not experienced enough to devise a solution by VBA. So a point in
the right direction would be really useful.
Thanks
Zack


Open the form from the Report's Open event, then check if it is still
open. If not, cancel the event (and the report).

If you have Access 2000 or newer:
Code the Report's Open event:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog

If Not CurrentProject. AllForms("3_Str ikes_Search").I sLoaded Then
MsgBox "Report has been cancelled"
Cancel = True
End If

If the Report has been opened from a code event (on a switchboard, for
example), closing the report will generate error 2501. Trap that error
in the switchboard event:

On Error GoTo Err_Handler
DoCmd.OpenRepor t "3_Strikes" , acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Fred, Thank you for your response, this issue is that I have inherited
this database and so is still in Access 97. Could you help with a
conversion of the above code that would work in 97.
Many thanks
Zack


Access 97 did not come with a built-in IsLoaded function so copy this
function (which is from the Northwind.mdb sample database) into a new
Module. Do not make any changes to it:

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or
Datasheet view.

Const conObjStateClos ed = 0
Const conDesignView = 0

If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
conObjStateClos ed Then
If Forms(strFormNa me).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function

Then change the code in the Report's Open event to:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog
If Not IsLoaded("3_Str ikes_Search") Then
MsgBox "Report has been cancelled"
Cancel = True
End If

The code to trap error 2501 stays the same as I previously wrote.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
May 5 '06 #4

fredg wrote:
On 5 May 2006 02:40:23 -0700, zack wrote:
fredg wrote:
On 3 May 2006 03:54:15 -0700, zack wrote:

Any help with this would be greatly appreciated, as cannot work out how
to resolve.

I have a report called "3_Strikes" . In its 'On open' event is command
to also open a criteria form popup form called, "3_Strikes_Sear ch".
The purpose of the form is to allow input of data to filter the results
of the report, (In this case mail-merged letters).

The issue I have is that when I open the report via a command button,
the "3_Strikes_Sear ch" form pops up. However if at this stage I decide
not to run the report, I cant close the pop-up form without various
error messages.

I imagine this is because the Open Report event has already taken place
in the background.

The first error is when click on the close button is:
This action cant be carried out while processing a form or report
event.
When I click okay it then prompting for date via parameter query input
boxes.

I am not experienced enough to devise a solution by VBA. So a point in
the right direction would be really useful.
Thanks
Zack

Open the form from the Report's Open event, then check if it is still
open. If not, cancel the event (and the report).

If you have Access 2000 or newer:
Code the Report's Open event:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog

If Not CurrentProject. AllForms("3_Str ikes_Search").I sLoaded Then
MsgBox "Report has been cancelled"
Cancel = True
End If

If the Report has been opened from a code event (on a switchboard, for
example), closing the report will generate error 2501. Trap that error
in the switchboard event:

On Error GoTo Err_Handler
DoCmd.OpenRepor t "3_Strikes" , acViewPreview
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Fred, Thank you for your response, this issue is that I have inherited
this database and so is still in Access 97. Could you help with a
conversion of the above code that would work in 97.
Many thanks
Zack


Access 97 did not come with a built-in IsLoaded function so copy this
function (which is from the Northwind.mdb sample database) into a new
Module. Do not make any changes to it:

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or
Datasheet view.

Const conObjStateClos ed = 0
Const conDesignView = 0

If SysCmd(acSysCmd GetObjectState, acForm, strFormName) <>
conObjStateClos ed Then
If Forms(strFormNa me).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function

Then change the code in the Report's Open event to:

DoCmd.OpenForm "3_Strikes_Sear ch", , , , , acDialog
If Not IsLoaded("3_Str ikes_Search") Then
MsgBox "Report has been cancelled"
Cancel = True
End If

The code to trap error 2501 stays the same as I previously wrote.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Fred, Thanks for the response. It was really useful. I am still getting
an error popup,
'The OpenReport action was cancelled', but I am sure I will get there.
Thanks for all your help.
Zack

May 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10317
by: Daniel Chartier | last post by:
Hello. I have a question concerning variable criteria for queries and reading forms. Let's say that I have a table with 2 fields and 10 records. One of the fields can have two different values: A or B. Then let's say that I've designed a slpit form. The right side of the form allows for data entry while the left side allows for record...
19
3520
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main form, the subform returns the records based on the two criteria. The criteria used on the main form are values selected in two list boxes. When the...
3
11058
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such as dates) in a text box. This procedure works fine. However, I also need to enter data from a combo box and I cannot get this to work. On my form...
4
4027
by: EJO | last post by:
In the query builder, I can create a query that will take a date/time as criteria, and the query finds the records: SELECT SRSrvcsEquip.Stock, SRSrvcsEquip.Activity, SRSrvcsEquip.EquipOwned, SRSrvcsEquip.Manufacturer, SRSrvcsEquip.EHSN, SRSrvcsEquip.Qty, SRSrvcsEquip.PartNumber, SRSrvcsEquip.Description, SRSrvcsEquip.ListType,...
2
4227
by: rinmanb70 | last post by:
I have a QBF form/query and a report from the QBF that shows the results of the QBF. I would like to show the criteria on the report that was used in the QBF to get the info on report. I can't find how to do this except to show the "hard for users to understand" SQL WHERE statement. Anyone have a better way?
8
3854
by: Ragbrai | last post by:
Howdy all, I have a form for entering data (Form A), on which is a cmd button that opens Form B in acdialog mode to allow me to enter/edit records that are being displayed on Form A. After adding/editing a record on Form B (opened in acDialog mode), I want a cmd button on Form B to close Form B and then have Form A automatically take me to...
1
1568
by: Arnold | last post by:
Greetings, I have a form, frmProgressReports, with qryProgressReports as the recordsource. A field in the query is named 'Select" and is yes/no, with criteria set to true. This filters the form so that only students who are in a teacher's class are available in the form. At the top of the form is an unbound combobox, cboStudents, used to...
1
1898
by: DrJarmin | last post by:
Hello The problem is this: in the criteria for a list box I reference the parent form - and Access KEEPS changing the criteria for one that won't work. Details below: I have a couple of list boxes on a form. In the row source I use the primary key of the form as a criteria. For example, I have company details on the form. The list box...
5
8099
by: Brett | last post by:
Hello, Is it possible to have just one criteria and have it apply to a group of queries? I am trying to create a report with the separate results of 4 queries based on a prompt for the user to input (only once) a date. Is this something that I program into the report? Also, this is related but may require a separate posting, but can I...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.