Important alert: (current site time 7/15/2013 6:56:13 PM EDT)
 

article

Access 2000: Controlling Report Data

Email
Submitted on: 11/25/2011 5:24:54 PM
By: davepamn 
Level: Beginner
User Rating: By 5 Users
Compatibility: SQL Server 2000, SQL Server 7.0
Views: 20863
(About the author)
 
     It is often the case a developer will need to create an Access 2000 reports application capable of data selection. For example, all transactions for a member. The data is input as parameters with in a form and passed to the report as query criteria. This is the simplest method to control report output resulting from user selected data criteria.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				
Access 2000: Launching a report

It is often the case a developer will need to create an Access 2000 reports application capable of data selection. For example, all transactions for a member. The data is input as parameters with in a form and passed to the report as query criteria. This is the simplest method to control report output resulting from user selected data criteria.

Table Transactions
Fields and Types
MemberIdNumber
PostedDatePostedDater
AmountDouble
CodeNumber
		
Create a query called qryTransactions
	include memberid, posteddate,amount, and code in the query field list
Create a columar report called rptTransactions
	Step 1: Use the report Wizard 
	Step 2: Select qryTransactions as the data source
	Step 3: Select all fields
	Step 4: Group on memberid
	Step 5: Select Tabular type
	Step 6: Name the report rptTransactions
Create a form called frmReportParameters
	Step 1: Design View
	Step 2: Add a text field called txtMemberId
	Step 3: Change the label to read "Member Id"
	Step 4: Add a button named "cmdLaunchTransactionReport" and labeled "Launch Report"
	Step 5: Save the form as frmReportParameters
Launch the Code
	Step 1: Make sure your in form design
	Step 2: Press the code button
	Step 3: Add a Click event for the cmdLaunchTransactionReport button
	

The following code will limit data selection to records matching
a specific member id. The report will open in preview mode. Only
transactions with a specific member id will be displayed.

Option Explicit
Option Compare Database
Private Sub cmdLaunchTransactionReport_Click()
On Error GoTo Err_cmdLaunchTransactionReport_Click
 Dim stDocName As String
 Dim stLinkCriteria As String
 Dim sCriteria
 sCriteria = "[MemberId]=" & txtMemberId
 stDocName = "rptTransactions"
 DoCmd.OpenReport stDocName, acViewPreview, , sCriteria, acWindowNormal
Exit_cmdLaunchTransactionReport_Click:
 Exit Sub
Err_cmdLaunchTransactionReport_Click:
 msgbox Err.Description
 Resume Exit_cmdLaunchTransactionReport_Click
End Sub
Run the Form
Step 1: Press F5
Step 2: Enter in a Member Id
Step 3: Press the Launch Report Button
Step 4: Review your report


Other 9 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

8/27/2003 1:31:51 PMMike J Anderson

Actually you can do it much easier with a parameter query.
(If this comment was disrespectful, please report it.)

 
6/28/2004 5:48:59 AM

good one
(If this comment was disrespectful, please report it.)

 
7/18/2004 2:58:18 AM

I'm interested in any further SQL
entries you have, as I am studying this language
Do you have any other scripts which
work with SQL server on XP?
Thanks,
Chris
(If this comment was disrespectful, please report it.)

 
7/23/2008 9:24:06 AMron

im just a newbies in SQL can you help me in basic.........?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.