I have a report (JobVacanciesOn ly) that has a subreport (JobVacanciesOn lySR) that are based on two separate queries.
MY - JobVacancyJobs - SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum, Grade.Midpoint, Grade.Maximum, Job.EEOCategoryCode, EEOCategory.Desc, Job.EEOSubCategoryCode, EEOSubCategory.Desc
-
FROM Grade RIGHT JOIN (EEOSubCategory RIGHT JOIN (EEOCategory RIGHT JOIN Job ON EEOCategory.Code = Job.EEOCategoryCode) ON EEOSubCategory.Code = Job.EEOSubCategoryCode) ON Grade.Code = Job.Grade
-
ORDER BY Job.Title, Job.Code;
MY - JobVacancies - SELECT JobVacancy.JobCode, JobVacancy.DepartmenCode, JobVacancy.DivisionCode, JobVacancy.NumberofPositions, Department.Desc, Division.Desc
-
FROM (JobVacancy LEFT JOIN Department ON JobVacancy.DepartmenCode = Department.Code) LEFT JOIN Division ON JobVacancy.DivisionCode = Division.Code
-
GROUP BY JobVacancy.JobCode, JobVacancy.DepartmenCode, JobVacancy.DivisionCode, JobVacancy.NumberofPositions, Department.Desc, Division.Desc
-
ORDER BY JobVacancy.JobCode, JobVacancy.DepartmenCode, JobVacancy.DivisionCode;
There is a textbox on the main report that calculates the total number of vacancies for each job position
[code]TotalVacancies= IIf(((DSum("[NumberofPositio ns]","JobVacan cy", "[JobVacancy.JobC ode]=[code]"))-DCount("[MY - ActiveEmpJob]![ID]","MY - ActiveEmpJob"," [MY - ActiveEmpJob]![JobCode] =[code]"))<0,0,((DSum( "[NumberofPositio ns]","JobVacan cy", "[JobVacancy.JobC ode]=[code]"))-DCount("[MY - ActiveEmpJob]![ID]","MY - ActiveEmpJob"," [MY - ActiveEmpJob]![JobCode] =
and a textbox in the subreport that calculates the number of vacancies for that job position, in a specific department and division
[code]NumVacancies=II f([NumberofPositio ns]-(DCount(" [MY - ActiveEmpJob]![ID]","MY - ActiveEmpJob"," [MY - ActiveEmpJob]![JobCode] = Reports![JobVacanciesOnl y]![code] AND [MY - ActiveEmpJob]![DivisionCode] = [MY - JobVacancies]![DivisionCode] "))<0,0,[NumberofPositio ns]-(DCount(" [MY - ActiveEmpJob]![ID]","MY - ActiveEmpJob"," [MY - ActiveEmpJob]![JobCode] = Reports![JobVacanciesOnl y]! - AND [MY - ActiveEmpJob]![DivisionCode] = [MY - JobVacancies]![DivisionCode] ")))
What I want to do now, is filter my report so that when it opens, it only shows the records that have NumVacancies or TotalVacancies with a value greater than 0 (basically I want it to only display the records where there is a job vacancy). It would seem that the easiest method would be to filter this in a query, but after over a week of trying to get a query to calculate the vacancies for me, it seems that with my dataset, it is not possible to get the desired results - hence the 2 queries above. So......is there any way to filter this based on a calculated value textbox that is on the report?? My VBA is very very limited, so please don't oversimplify if that's what I need to be using. Thanks in advance!
Jul 27 '07
94 6898
I meant subreport, not subform
Access processes the Open event before it runs the query that provides the report with its data, so I have not found any way to filter the report without creating an updated recordset from the report’s recordset that includes the effect of the parameters. Try this and let me know. -
Private Sub Report_Open(Cancel As Integer)
-
On Error GoTo Error_Routine
-
-
Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
Dim qdf As DAO.QueryDef.
-
-
Set db = CurrentDb()
-
Set qdf = db.QueryDefs("JobVacancyJobs")
-
qdf.Parameters(1) = Me![TotalVacancies].Value > 0
-
qdf.Parameters(2) = Me![JobVacanciesOnlySR].Report![NumVacancies].Value > 0
-
Set rs = qdf.OpenRecordset()
-
-
rs.Close
-
-
DoCmd.Maximize
-
-
Exit_Continue:
-
Set rs = Nothing
-
Set qdf = Nothing
-
Exit Sub
-
Error_Routine:
-
MsgBox "Error " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
End Sub
-
Access processes the Open event before it runs the query that provides the report with its data, so I have not found any way to filter the report without creating an updated recordset from the report’s recordset that includes the effect of the parameters. Try this and let me know. -
Private Sub Report_Open(Cancel As Integer)
-
On Error GoTo Error_Routine
-
-
Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
Dim qdf As DAO.QueryDef.
-
-
Set db = CurrentDb()
-
Set qdf = db.QueryDefs("JobVacancyJobs")
-
qdf.Parameters(1) = Me![TotalVacancies].Value > 0
-
qdf.Parameters(2) = Me![JobVacanciesOnlySR].Report![NumVacancies].Value > 0
-
Set rs = qdf.OpenRecordset()
-
-
rs.Close
-
-
DoCmd.Maximize
-
-
Exit_Continue:
-
Set rs = Nothing
-
Set qdf = Nothing
-
Exit Sub
-
Error_Routine:
-
MsgBox "Error " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
End Sub
-
I tried your code and I get an Error: "Error 3265 Item not found in this collection"
I tried your code and I get an Error: "Error 3265 Item not found in this collection"
Okay I made an adjustment to your code because it did not have the proper query name. - Set qdf = db.QueryDefs("MY - JobVacancyJobs")
(main report based on that query) which only has the fields Job Code, Job Title, Job Grade, Job Level, Job Group, and I got an error so I tried - Set qdf = db.QueryDefs("MY - JobVacancies")
(subreport based on that query) which has the fields JobCode, DepartmentCode, DivisionCode, NumberofPositio ns and I get the same error as the above code: Error 2427 You entered an expression that has no value.
Is this because TotalVacancies and NumVacancies are not actually in the query, but calculated on the report/subreport? When I click OK, it goes to my report, but doesn't filter anything.
Okay I made an adjustment to your code because it did not have the proper query name. - Set qdf = db.QueryDefs("MY - JobVacancyJobs")
(main report based on that query) which only has the fields Job Code, Job Title, Job Grade, Job Level, Job Group, and I got an error so I tried - Set qdf = db.QueryDefs("MY - JobVacancies")
(subreport based on that query) which has the fields JobCode, DepartmentCode, DivisionCode, NumberofPositio ns and I get the same error as the above code: Error 2427 You entered an expression that has no value.
Is this because TotalVacancies and NumVacancies are not actually in the query, but calculated on the report/subreport? When I click OK, it goes to my report, but doesn't filter anything.
No, the recordset should reflect the effect of querydef and parameter. try eliminating parameter 2 (line 11) and see if main report reflects parameter 1.
No, the recordset should reflect the effect of querydef and parameter. try eliminating parameter 2 (line 11) and see if main report reflects parameter 1.
Removing parameter 2 gives the same error: Error 2427 You entered an expression that has no value.
Removing parameter 1 and changing parameter 2 to parameter 1 gives Error 2455 You entered an expression that has an invalid reference to the property Form/Report - qdf.Parameters(1) = Me![JobVacanciesOnlySR].Report![NumVacancies].Value > 0
My mistake, I meant for you to remove the parameter for the subreport not the one for the main report.
My mistake, I meant for you to remove the parameter for the subreport not the one for the main report.
Sorry, I mustn't have been clear in that last post. I removed the parameter for the subreport and it gave me the Error 2427 You entered an expression that has no value.
When that didn't succeed, I tried removing the parameter for the main report instead, and that gave me the Error 2455 You entered an expression that has an invalid reference to the property Form/Report.
Would it be any easier to do the calculation of TotalVacancies and NumberofVacanci es in VBA rather than referring to the textbox on the report? I'd probably still have the same problem of the queries not executing first, though, wouldn't I?
Would it be any easier to do the calculation of TotalVacancies and NumberofVacanci es in VBA rather than referring to the textbox on the report? I'd probably still have the same problem of the queries not executing first, though, wouldn't I?
Yes. The easiest way would be to include it in each of your select statements. Strangely enough, per this link, you can include a textbox in your select statement...the link uses a textbox on a form as an example but I think it could be a textbox on a report also.
see comment by Duane Hookum http://www.tek-tips.com/viewthread.c...361948&page=15
I am still researching this, but you are welcome to try the method outilined in the above link, including your report textbox in each of the select statement as illustrated by Hookum in the above link with the selection list inclusion of the textbox from a form. Be sure and include the full reference to your textboxes, e.g. Reports![JobVacanciesOnl y]![TotalVacancies].Value > 0......
Yes. The easiest way would be to include it in each of your select statements. Strangely enough, per this link, you can include a textbox in your select statement...the link uses a textbox on a form as an example but I think it could be a textbox on a report also.
see comment by Duane Hookum http://www.tek-tips.com/viewthread.c...361948&page=15
I am still researching this, but you are welcome to try the method outilined in the above link, including your report textbox in each of the select statement as illustrated by Hookum in the above link with the selection list inclusion of the textbox from a form. Be sure and include the full reference to your textboxes, e.g. Reports![JobVacanciesOnl y]![TotalVacancies].Value > 0......
Okay, now my question is this. I created my queries in the query design view, not in vba. Does that make a difference? Would I just add the textbox reference to my already existing query or should I have created the report based on a query written in vba?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: CSDunn |
last post by:
Hello,
I have a problem with field filtering between an Access 2000 Project form
(the application is called CELDT), and the report that shows the results of
the filter. Both the form and the report are based on the same View
addressed in the Record Source of both as 'dbo.CLMain_vw'. The View resides
in a SQL Server 2000 database. There are two different problems I am having
with filtering: The first involves filtering in the form by date...
|
by: Richard |
last post by:
Hi,
I have a form based on a table. When I filter the form I want to run a
report based on the same table with the same filter as the form. No problem
until I want to filter a combo box where the text value is on a different
table. The me.filter is then a text instead of the id-number from the lookup
table. This causes the report to prompt for the parameter.
How do I get by this problem? Do I need to create a temporary table? I
rather...
|
by: damjanu |
last post by:
Hi All;
I need little help.
I have a datasheet form.
I allow user to do 'filter by selection'.
My form contains a column with values.
As user changes selections, I want to
calculate totals. I can do this the
first time the form loads.
|
by: Nathan Bloomfield |
last post by:
Does anyone know if there is any documentation which relates to Access2k + ?
or can anyone help adjust the code?
I am having trouble converting the DAO references.
TITLE :INF: How to Create a Dynamic Crosstab Report
PRODUCT :Microsoft Access
PROD/VER:1.00 1.10
OPER/SYS:WINDOWS
|
by: ahaque38 |
last post by:
Hello.
Using A2K SP3, I am having the following problem with a report using
"Sorting and Grouping".
I have recently added a grouping in the reports for
"Category2<>'CONTRACTS'".
I have reports at the plan (overall totals), department and division
levels which have sorting and grouping implemented with this new
| |
by: Seth Delaney |
last post by:
I have a form with multiple unbound text boxes which serves as a
"search form". I can enter my search parameters in the various boxes
as needed and click okay. My records are then filtered to produce the
results I want in a separate form (filter by form). No problem, except
I want to save the sql to a query, not a form.
When I debug.print the various sql, I get something like this example:
(( LIKE "cam*"))
which obviously is not enough...
|
by: shobhit_shanker |
last post by:
Here are the relevant "givens" to my problem...
Form: frmLaunchRpt
- Text Box: txtAsOfDate
- Check Box: chkLogEval
- Command Button: cmdLaunchRpt
Report: rptEvaluation
- Text Box: txtGreen (Percent of items on schedule)
- Text Box: txtYellow (Percent of items slightly off schedule)
|
by: kelley.l.turner |
last post by:
Hi all,
I am very new to MS Access so please bear with me! I have created a
simple calculated field in my data entry form, yet when I view my data
table or try to generate a report based on this calculated field, no
value is posted. How/where do I get my calculated values to also show
up in the tables and reports?
Thanks,
Kelley
|
by: jcf378 |
last post by:
hi all.
I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ).
However, when I click "Filter by Form" in order to search for records based on this form, I would like to be able to enter a value in this "days" control so that I can filter records on the form based on this calculated interval (i.e., i want to search for records specifically where...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |