By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,830 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,830 IT Pros & Developers. It's quick & easy.

create a form to enter report criteria

P: 27
I have created a form per MS Access help for search criteria for a reportand it works great. But is there a way to do it for an edit form? I have duplicated the method and can get 95% of the problem solved however, the "Cancel" button won't work. I can close out of the critera form but I get left hanging in the original edit form. I have set it up in VB on open in the edit form. I use the same criteria form for different edit forms and it works great until I hit the "Cancel" button in them.
May 22 '07 #1
Share this Question
Share on Google+
7 Replies

puppydogbuddy
Expert 100+
P: 1,923
I have created a form per MS Access help for search criteria for a reportand it works great. But is there a way to do it for an edit form? I have duplicated the method and can get 95% of the problem solved however, the "Cancel" button won't work. I can close out of the critera form but I get left hanging in the original edit form. I have set it up in VB on open in the edit form. I use the same criteria form for different edit forms and it works great until I hit the "Cancel" button in them.

Please post the code behind your Cancel button. Thanks.
May 23 '07 #2

P: 27
I used the instruction from the ms Access help for "create a form to enter report criteria" and works great for a report, but I need it for a form. Below is how I set it up with my form of "srchVariable".
-------------------------------------
Create a macro for the Cancel button.

How?

This macro closes the form. Give the macro a name, such as Cancel, and click the Close action. Then set its action arguments as follows:

Argument Setting
Object Type Form
Object Name srchVariable
Save No
-------------------------------------
Create a macro that opens the Sales Dialog form.
How?

Begin by clicking Macro Names to display the Macro Name column. Type a macro name, such as Open Dialog, in the Macro Name column, and then click the OpenForm action. Then set the action arguments as follows.
Argument Setting
Form Name srchVariable
View Form
Data Mode Edit
Window Mode Dialog

Add a second action, CancelEvent, that cancels previewing or printing the report when the Cancel button on the form is clicked.

If the Condition column is not displayed, click Conditions .

Type the following expression in the Condition column:

Not IsLoaded("srchVariable")

Note IsLoaded is a function defined in the Utility Functions module in the Northwind sample database. It's used to check whether a form is open in Form view or Datasheet view. You must define the IsLoaded function in your database before you can use it. (You can copy and paste this function from Northwind into a utility module in your database.)
-------------------------------------
Option Compare Database
Option Explicit

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

Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If

End Function
Jun 4 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
Have you got it working or not? If it is not working, please provide more details. Thanks.
Jun 4 '07 #4

P: 27
Have you got it working or not? If it is not working, please provide more details. Thanks.

It works until I go to cancel in the form. The macro halts due to the original form that I used is looking for the data that was in the search form. Since it has closed, there is not data to search for.
Jun 5 '07 #5

puppydogbuddy
Expert 100+
P: 1,923
It works until I go to cancel in the form. The macro halts due to the original form that I used is looking for the data that was in the search form. Since it has closed, there is not data to search for.
Try changing this:
Argument Setting
Form Name srchVariable
View Form
Data Mode Edit
Window Mode Dialog <----------------------------------

To this:
Argument Setting
Form Name srchVariable
View Form
Data Mode Edit
Window Mode Normal <----------------------------------

Opening the form in dialog mode suspends the execution of all other code until the user responds to the dialog prompt or closes the form.
Jun 5 '07 #6

P: 27
It worked to get the "srchVariable" form to close without a error, however when opening original form, the srcVariable form is not out front now. The cancel button works for that form when I bring it to the front, but the original form hasn't closed yet. I ended up putting the following line in code for opening the original form rather that in the macro and it works great:

If Not IsLoaded("srchVariable") Then
...

Thank you for the help.
Jun 5 '07 #7

puppydogbuddy
Expert 100+
P: 1,923
It worked to get the "srchVariable" form to close without a error, however when opening original form, the srcVariable form is not out front now. The cancel button works for that form when I bring it to the front, but the original form hasn't closed yet. I ended up putting the following line in code for opening the original form rather that in the macro and it works great:

If Not IsLoaded("srchVariable") Then
...

Thank you for the help.
You are most welcome. Glad I could help. Just so you know there are several ways that you could have solved your active screen problem. For example, you could have experimented and tweaked the popup and modal property settings of the two forms, with the bottom form set as Popup = No; modal = no and the form you wanted on the top could have been set Popup = yes and modal = ? maybe Yes. And there are other ways.....the way you chose is as good as any.
Jun 5 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.