473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Filter on Load Report Based on A Form ComboBox

11
For my question here are the following:

Form Name: popup; Combo1 is the name of the Combobox I want to pass information to my report on load to filter the report output.
Query report is based on: Open Issues
Report Name: Active Issues by Physician (field I want to filter is Provider Name)

I have the form built and here is the code behind the cmd button set OnClick:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command6_Click()
  2.  
  3.  
  4. On Error GoTo MyError
  5.  
  6.  
  7.  
  8.  
  9.     DoCmd.OpenReport "active issues by physician", acViewReport
  10.  
  11.  
  12.  
  13. Leave:
  14.  
  15.  
  16.     Exit Sub
  17.  
  18. MyError:
  19.  
  20.  
  21.     MsgBox "Error " & Err.Number & ": " & Error$
  22.     Resume Leave
  23.  
  24.        End Sub
I have also set my report to Yes for the Filter on Load property for the Report as the Selection Type. In the Filter property I have the following:

Expand|Select|Wrap|Line Numbers
  1. Provider Name=forms![popup]![combo1]
Currently, I'm getting my report output as if I have not selected anything in my ComboBox from the popup form.

Any and all help is much appreciated!!
Aug 3 '12 #1

✓ answered by Seth Schrock

Check the Bound To Column property. It needs to be set to 1 if the query needs the ID field or 2 if it needs the [Provider Name] field. I'm guessing that since the criteria is
Expand|Select|Wrap|Line Numbers
  1. WHERE [Provider Name] = Form!popup!cboprovidername
that the query is looking for the text value (provider name) and not the number field (ID). If this is the case, then you need the Bound To Column to be 2, while the default is 1. Usually, queries are based on the primary key fields and not the text fields, so Access defaults to this design.

7 7840
Seth Schrock
2,965 Expert 2GB
What I would do is create a query that has the WHERE clause being the
Expand|Select|Wrap|Line Numbers
  1. [WHERE [Provider Name] = Forms!popup!combo1
Then you can base the report on that query and the results will be filtered every time.

Hint: It really helps to name your controls so that they tell you what they contain. For example, you could name your combo1: cboProviderName. That way whenever you see it in your code, you know which control you are referring to.
Aug 4 '12 #2
bkyzer
11
Thanks for the information. I've taken your advice and tried that route but I'm still hitting a stumbling block. Here is what I have in the Criteria field of the Query for the Provider Name:
Expand|Select|Wrap|Line Numbers
  1. =[Forms]![popup]![cboprovidername]
(I changed my referenced ComboBox to cboprovidername)

However, I'm still getting a blank report. I tried putting in manually one of the items that is in my combobox list directly into the WHERE statement and it worked beautifully for that one item typed in. Why is my ComboBox not talking to the query? That seems to me to be the issue?

Thanks!!
Aug 4 '12 #3
Seth Schrock
2,965 Expert 2GB
What is the row source for cboprovidername? If it is the name of a query, please attach the SQL code for that query.

Another method to troubleshoot what is happening, click on gray area to the left of row 9 in your OP where it is in the VBA editor. A read dot should appear. Then click your button. The code will stop at that point before it executes your code. In the Immediate window, type ?Me.cboprovidername (the Immediate window should be on the bottom of the VBA editor. If not, press Ctrl + G and it will appear). This will tell you the value that the combo box is passing to the query.
Aug 4 '12 #4
bkyzer
11
Here is the SQL from the row source of cboprovidername:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Providers].[ID], Providers.[Provider Name] FROM Providers; 
In the meantime, I'm going to try the steps you've mentioned above with checking to see if the information is passing through.


Just tried the 2nd troubleshooting issue you mentioned and the immediate window retains ?Me.cboprovidername with no change or display of the value I selected in my cboprovidername ComboBox.
Aug 4 '12 #5
Seth Schrock
2,965 Expert 2GB
Check the Bound To Column property. It needs to be set to 1 if the query needs the ID field or 2 if it needs the [Provider Name] field. I'm guessing that since the criteria is
Expand|Select|Wrap|Line Numbers
  1. WHERE [Provider Name] = Form!popup!cboprovidername
that the query is looking for the text value (provider name) and not the number field (ID). If this is the case, then you need the Bound To Column to be 2, while the default is 1. Usually, queries are based on the primary key fields and not the text fields, so Access defaults to this design.
Aug 4 '12 #6
bkyzer
11
Brilliant!!! Thank You SO Much. That did it! I've been fighting this all afternoon.
Aug 4 '12 #7
Seth Schrock
2,965 Expert 2GB
Not a problem. Glad I could help. Keep what you've learned here. You will probably use it MANY times as you create/modify databases.

Back to the control naming thing, here is a link that tells the most commonly used naming: Naming Convention Just replace the X's with something that tells you what the control contains. Keeping spaces out of the names also helps when coding.
Aug 4 '12 #8

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

Similar topics

3
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...
2
by: Rosy | last post by:
I am attempting to use the following code to print a report based on the current record in the form. Users bring up the record with a parameter box and then can make changes to the sub-form on the...
0
by: mike11d11 | last post by:
I have a form with a dataset that contains account records in one table and another table that contains transactions for accounts that are in the other table. I'm trying to create a report based...
5
by: favor08 | last post by:
have a mainform called PendingsMain and a subform called PendingsSub. You can filter the subform by different filters and this works fine. i want to create a report that will print out the...
5
by: jonosborne | last post by:
Hi, i have managed to filter a report based on selections made in a list box but am totally confused with a message box that appears everytime i run my report. Let me explain (i apologise for...
94
by: mlcampeau | last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries. MY - JobVacancyJobs SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum,...
6
by: pouj | last post by:
what i want to do is basically have form where my selection in the combox make the diffrence with what the form reports. this is what the underlying informaion is.... software is access 2007 i...
11
by: billa856 | last post by:
Hi, I have project in MS Access.In that I have one form in which there is one combobox .I want to know when I select an item from that combobox and click on submit button then it should open a...
1
by: Joelle | last post by:
Hi everyone, i am really stack!i need help I have this report:"RequirementObjects_Report",i have also a multiselect listbox whicg contains a list of products.what i want to do is to filter the...
4
Seth Schrock
by: Seth Schrock | last post by:
I have a database that is keeping track of returned mail. Each piece of returned mail has a status. I want to be able to view reports for all the returned mail in each status. I could create a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.