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

Creating a form to enter parameters into a report

Hi There,

I need to create a form with 3 fields (registratonNum, startDate and endDate).

I want to make a report that will show data based on the registrationNum passed into the form during the time frame (startDate to endDate) specified in the form. I'm new to access and I can't seem to get this to work.

Any help would be greatly appreciated.

Thank you.
May 18 '12 #1
4 2096
anoble1
245 128KB
Dave,

Maybe I can help out a little bit for now. Just create a regular form. Get a Text Box for the registrationNum. The 2 more text boxes for your date fields. There are several ways to do the limiting with your 3 options.

of course you will have to change some stuff to make your custom report work.. :)

I had to make a table to handle my reports. An ID field, Report name field, then the rptWhateverregistration

I made something similiar, On the report Drop down I used this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbReportName_AfterUpdate()
  2.  
  3.     ResetOptions
  4.     If Nz(cmbReportName.Value, "") <> "" Then
  5.         'Grab the report name and return the Filters below
  6.         If GetObjectName(cmbReportName.Value) <> "" Then cmdView.Enabled = True
  7.  
  8.         Select Case cmbReportName.Value
  9.             Case 1
  10.                 'Customer Account Type 
  11.                 Me.RegistrationNum.Enabled = True
  12.                 Me.startDate .Enabled = True
  13.                 Me.endDate.Enabled = True
  14.                 cmdView.Enabled = True    
  15.             Case 2
  16.                 'Report 2
  17.                 Me.RegistrationNum.Enabled = True
  18.                 Me.startDate .Enabled = True
  19.                 Me.endDate.Enabled = True
  20.                 cmdView.Enabled = True    
  21.  
  22.         End Select
  23.     Else
  24.  
  25.  
  26.     End If
  27.  
  28. End Sub
Then when you click the VIEW button with the criteria:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdView_Click()
  2.  
  3. If Nz(cmbReportName.Value, "") <> "" Then
  4. DoCmd.OpenReport GetObjectName(cmbReportName.Value), acViewPreview, , GetWhereCond
Then I created a new module
Expand|Select|Wrap|Line Numbers
  1. Public Function GetObjectName(id As Integer) As String
  2.  
  3. Dim records As Recordset
  4. Dim sqlStatement As String
  5. Dim returnValue As String
  6.  
  7.     'Grab the number in tblReportName and grab the Report Name
  8.     sqlStatement = "SELECT * FROM tblReportName WHERE ReportID = " & id
  9.     Set records = CurrentDb.OpenRecordset(sqlStatement)
  10.     If records.EOF Then
  11.         returnValue = ""
  12.     Else
  13.         returnValue = Nz(records("ObjectName"), "")
  14.     End If
  15.     records.Close
  16.  
  17.     'Records the string and changes the name
  18.     GetObjectName = returnValue
  19.  
  20. End Function
Expand|Select|Wrap|Line Numbers
  1. Public Function GetWhereCond() As String
  2.  
  3. Dim whereCond As String
  4.     'Use the Report Main Form
  5.     With Forms!frmMain
  6.  
  7.                 If Nz(!registratonNum.Value, "") <> "" Then whereCond = whereCond & " AND (registratonNum = " & """" & !registratonNum.Value & """" & ")"
  8.         If Nz(!startDate.Value, "") <> "" Then whereCond = whereCond & " AND (startDate = " & """" & !startDate.Value & """" & ")"
  9.         If Nz(!endDate.Value, "") <> "" Then whereCond = whereCond & " AND (endDate = " & """" & !endDate.Value & """" & ")"
  10.  
  11.  
  12.     End With
  13.  
  14.     If whereCond = "" Then
  15.         GetWhereCond = ""
  16.     Else
  17.         GetWhereCond = "(" & Right(whereCond, Len(whereCond) - 5) & ")"
  18.     End If
  19.  
  20. End Function
May 18 '12 #2
Wow thank you for the detailed response. I'll give it a shot.
May 18 '12 #3
NeoPa
32,556 Expert Mod 16PB
The concepts within Example Filtering on a Form should help with this. Instead of filtering the current form you open a report with the same filter string prepared.
May 18 '12 #4
zmbd
5,501 Expert Mod 4TB
You might also take a look at:
http://office.microsoft.com/en-us/ac...001117077.aspx

I often use parameter based queries using a form for simple reports...

-z
May 20 '12 #5

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

Similar topics

7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
0
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 Does anybody have US Accounts Payable Miscellaneous Income Form 1099-Misc report object they want to share? Thanks, John
3
by: RC | last post by:
I can't quite grasp the concept of creating custom reports depending upon what options a user picks on a Form. For example, the user clicks on a "Print Reports" button and a Form pops up. On the...
7
by: Mike | last post by:
I have to pass a date from a form to a report query. I have written a query that works fine when I execute from SQL view, But I dont know how to pass a value from the form to this query. SELECT...
1
by: Apple | last post by:
May anyone can teach me how to use form to set report parameter, my design in FORM is : From to , Customer ID from , Index on
1
by: Rodo | last post by:
Hi all, I'm trying to generate a simple crystal report without a database. Several people mention the use of a dataset. Someone mention in a msdn forum that I could use the SetParameterValue to...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
2
by: PotatoChip | last post by:
I am working in Access 2002 and I have been asked to create a form for a report based on a paramter query so that the user selects the department from a drop down list on the form, query runs and...
3
by: fartash | last post by:
i have a command button on a form which opens report maximizeed form is also maximized with which i dont want
3
by: sorina | last post by:
I basically need a form like this: Start date: _____ End Date: _______ Trigger: ________ Whereby the start date, end date and trigger are the parameters to be keyed in by the end user before...
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:
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
0
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...
0
jinu1996
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...

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.