473,385 Members | 1,461 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,385 software developers and data experts.

Need to create a selective(filtered) lookup report (thingy?)

Ok I'm once again showing my complete (or almost) ineptitude with all things Access.

I'm using Access 2007 and need to do the following:

SETUP:

I have a table of membership information, and a table of dues information. They are linked via a unique ID number so that I can see the data for each entry without opening the corresponding table.

PROBLEM:

I need to create a form (or whatever I need to accomplish my goal) that basically allows me to select the filter parameters by clicking.

Like so maybe:

A form that uses a check box for each month. By selecting the months you want to see and then hitting a "Generate" button. It then generates a report of dues paid in those months, and displays them alongside a number and a name from the other table.

I have no idea how to link each check box to a field in a table and then getting all those selected to be joined in a report.

I'm not even sure it can be done.

Can anyone guide a hapless, gormless, ignorant rookie trying????

Please, with sugar on top?
Jul 14 '07 #1
13 3860
NeoPa
32,556 Expert Mod 16PB
Let's start with the concepts first then. We can sugar coat if you stick with it.
  1. You need a report to display the information. Don't worry at this stage about the filtering. Design a report that can show the whole dataset.
  2. You need a form to select your criteria from. On the form you need to put whatever controls are required to allow the operator to choose the criteria for selecting only the item(s) they want.
  3. When they have selected the selections, a Command Button control should be clicked to trigger your code to run the report.
  4. Your code needs to set up a filter string, the complexity of which is determined by your form.
  5. Lastly, your code needs to invoke the report, but should include passing the filter string in the invocation.
The effect of this will be that the report (which can show your whole dataset) will just show the filtered data - as you want it to.
Jul 15 '07 #2
Damn I was hoping to avoid using codes and I can't write that stuff.

Ok I now have a form that contains twelve check boxes and two command buttons. One button to open the report for the whole year and one that will operate the filter command.

I also have the report created to show the whole year.
Jul 15 '07 #3
NeoPa
32,556 Expert Mod 16PB
You'd be surprised what you can manage with a little help ;)

First of all, we need to know what your CheckBoxes are supposed to do. You can start with just a couple of them to give a general idea.

Now look in Example Filtering on a Form to see the concepts explained and even reproduce the example to get a good feel of this subject. When you've done that, come back and we can take you through it as it relates to your situation (if you even need any more help at that stage).
Jul 16 '07 #4
I haven't worked with VB code in over 10 years and that was an amateur effort. So help will definently be needed on that.

The checkboxes are all labeled "January, Febuary..." and so forth - one for each month

I also have one command button labeled "Show_Dues_Report" to open the report (Called "Dues_Report") showing the whole year.

Lastly I have one more command button labelled "Create_Report" intended to be used for the filtering code to only display those months that have been checked off in the Check Boxes.
Jul 16 '07 #5
NeoPa
32,556 Expert Mod 16PB
First of all you don't need to have two separate buttons to open the report.
One button can have code that checks the CheckBoxes and only adds the filter if any are checked (True).

Now, as in my earlier post (#4), I need you to look at the tutorial. This may sound harsh, but I don't want to work with you if you haven't tried it out, as that will be more work for me. If you find that you can't get it to work, let me know. I can work with that. What I can't (read am not prepared to) do is work with people who expect me to do all the donkey work for them. Not that I'm trying to suggest this is you. I'm simply redirecting you to that important bit of the previous post ;)
Jul 17 '07 #6
No problem with that, just wanted to stress the point that I am much more familair with Access thatn I am with writing anyything in code.

And that tutorial will be getting some me-time with me shortly.

Nice to know I only need the one button to operate the whole thing.

BUT since the form is set up so that all the code is in one command button, will there be diffucties in tying in the checkboxes to the code, or can it be made to see if functions outside it own object are triggered?
Jul 17 '07 #7
NeoPa
32,556 Expert Mod 16PB
...
BUT since the form is set up so that all the code is in one command button, will there be difficulties in tieing in the checkboxes to the code, or can it be made to see if functions outside its own object are triggered?
No. The code behind the button can refer quite easily to all the controls on the form. Checkboxes are particularly easy as you just say :
Expand|Select|Wrap|Line Numbers
  1. If [CheckBoxName] Then ...
to see if it's checked.
Jul 17 '07 #8
Ok I've been over the tutorial a few times, I think that I'll have to do it again and again cause that was hard reading for me right now.

But I figure that the structure of the code should be along these lines:

IF [Checkbox:January] Then print Table[Dues/Column January] to Report[Dues_Overview]
(obviously not correct formatted code, have no clue yet as to what that should be)
Repeated for other months

And I think I don't need anything special to print the whole thing as I think the structure of the VB code can be set up so that the filter is only activated when one or more checkboxes are used.

If not then I might simply need to start the code with another set of IF [Chechbox] commands to launch the filter code...

Am I on the right track with this...?
Jul 23 '07 #9
NeoPa
32,556 Expert Mod 16PB
Ok I've been over the tutorial a few times, I think that I'll have to do it again and again cause that was hard reading for me right now.

But I figure that the structure of the code should be along these lines:

IF [Checkbox:January] Then print Table[Dues/Column January] to Report[Dues_Overview]
(obviously not correct formatted code, have no clue yet as to what that should be)
Repeated for other months

And I think I don't need anything special to print the whole thing as I think the structure of the VB code can be set up so that the filter is only activated when one or more checkboxes are used.

If not then I might simply need to start the code with another set of IF [Chechbox] commands to launch the filter code...

Am I on the right track with this...?
Well, yes and no really.
Yes you do need to check the [CheckBox]es in your code.
No you would not do it in the way you're talking about.

Here's a very simple (as simple as I can make it but my explanations are sometimes considered obscure) explanation of the concepts.
  • When running a report, there is an option to Filter the results. IE. A report designed to show everything can be used, without changing the design of it in any way, to show selected items. This is done simply and easily by passing a Filter string when opening it.
  • What you need to do (and we can certainly help you here) is to create a string of SQL Filter words from the information contained on the form. The SQL string will contain the whole of the selection requirement before being passed to the DoCmd.OpenReport function.
  • You can build up the string, one item at a time, in your VBA code connected to the CommandButton that is clicked to run the report.
  • The resultant string is simply a list of checks which can be joined logically with AND and/or OR keywords. These checks are to be applied to each record as it is processed to determine whether it should be included in the results (report).
Jul 23 '07 #10
NeoPa
32,556 Expert Mod 16PB
Please be sure to read these recent posts in order. It would have been a bit of a chunk to read and get to grips with all at once.

A problem many people struggle with when applying filter strings is "How to apply the AND and OR keywords?"
Seems obvious, but if I said we wanted to see records that were from January AND February, but no other months, would you use AND or OR in the Filter string?
If you said AND then you'd be wrong.
The Filter is checking each record as it is processed. Can any record be from both January AND February? No, it can't (You'd have no results at all). For each record, you want to determine if it is either January OR February (even though you want to include records from January AND February in your results set).
Jul 23 '07 #11
NeoPa
32,556 Expert Mod 16PB
Please be sure to read these recent posts in order. It would have been a bit of a chunk to read and get to grips with all at once.

Now I need to make some assumptions as you haven't shared any information about what you have in your database. I will assume a simple table :
Table Name=tblDue
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. CustomerID; Autonumber; PK
  3. PayDate; Date/Time
  4. Amount; Number (Currency)
The [tblDue] table (in this assumed (and simple) scenario) is the RecordSource for the [rptDues] report. The form ([frmDues]) has twelve CheckBoxes named [chkJan] through [chkDec] and a CommandButton [cmdReport].
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdReport_Click()
  2.   Dim strFilter As String
  3.  
  4.   strFilter = ""
  5.   If Me.chkJan Then strFilter = strFilter & ",1"
  6.   If Me.chkFeb Then strFilter = strFilter & ",2"
  7.   If Me.chkMar Then strFilter = strFilter & ",3"
  8. .
  9. .
  10.   If Me.chkDec Then strFilter = strFilter & ",12"
  11.   If strFilter > "" Then
  12.     strFilter = "Month([PayDate] In(" & Mid(strFilter, 2) & ")"
  13.     Call DoCmd.OpenReport(rptDues, acViewPreview, ,strFilter)
  14.   Else
  15.     Call DoCmd.OpenReport(rptDues, acViewPreview)
  16.   End If
  17. End Sub
I chose to use the more appropriate In() construct for the Filter here as it fits in more neatly. It would be possible to create a string which had a bunch of clauses ORed together like :
Expand|Select|Wrap|Line Numbers
  1. (Month([PayDate])=1) OR (Month([PayDate])=3)
For a report showing January AND March Dues.

Please let me know how you get on with all this. If you do have problems, please try to explain exactly where, relative to what I was saying.
Jul 23 '07 #12
RZ15
53
I have a question regarding this.

NeoPa, what you have outlined, that results in a total amount due for the customer in whatever months selected, correct? Is there any way to show the months as fields and have amount due for each month shown if the query the report is based on used has a field for each corresponding month?

So if the user checked January and February, they will see the fields January and February and none of the other months.
Jul 23 '07 #13
NeoPa
32,556 Expert Mod 16PB
I'm sorry RZ, but your post (though it may seem connected) is off topic. You will need to post your own (separate) question about this. You may include a link to this one if you think that may help to explain it better, or even (in this case) a link from here to your new thread. That way experts involved in this thread may get a hook in. It also gives the opportunity for other experts to get involved. What you're asking is actually a lot more complicated and un-database like than maybe you realise.
Good luck with your question.
Jul 23 '07 #14

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

Similar topics

8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
1
by: bmoos1 | last post by:
I have two reports: 2004 New Enrollments and 2004 Cancellations. 1. Each report shows by month: "Monthly", "BiMonthly"(*2), "Weekly" (*52/12), "Total Monthly" (++) and "Projected...
1
by: cdolphin88 | last post by:
Hello, I'm new in creating report in Ms-Access and I have some questions. I want to display a text Hong Kong Dollars when a field in my database is = "HKD" and display a text Patacas when this...
8
by: sesmap | last post by:
I have a table which is a list of clients that we are sending to another company to contact for updating their account. I have a second table that is the other company's report back to me telling...
2
by: devindersingh1984 | last post by:
hello sir i am making a project in ms access it is having two tables that is interrelated with primary key. i want to get report of current record means report should take data from both tables....
1
by: tbehmand | last post by:
Hi I am getting the following message when I click on 'Create report in Design view', does anyone know how to fix this. "There was a problem retrieving printer information for this object. The...
1
by: alem | last post by:
Hi all help me how to create Report in SQL Server or SQL Query Analyzer. thank you in advance
6
by: alem | last post by:
Hallo pls help me how to create Report in Visual Basic.
1
by: SantyBhi | last post by:
Plz , any one can explain how to create report in c#asp.net without using Crystal Report.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.