Saturday, March 24, 2018

Display a Single Record in a Microsoft Access Report

Display a Single Record in a Microsoft Access Report

Steps

01.First create access database name it as test and then create a table called sample.

02.Then Create table as follows;


03. Enter sample data as follows;


04.Then create a Query based on the sample table and save it as a QrySample


05.Create a  report based on the QrySample.Name report as RptQrySample



06.Design a Form as follows;and Name it as frmReport.



07. Type following in your QrySample under the student id.
Like "*" & [forms]![frmReport]![txtID] & "*"


08.Write following code under the cmdSearch Button
On Error GoTo Err_cmd_Search_Click

    Dim stDocName As String

    stDocName = "RptQrySample"
   
'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

    If Me.txtID = "" Then
        MsgBox "Please ensure that a report date range is entered into the form"
        Exit Sub
    Else
       DoCmd.OpenReport stDocName, acViewReport
    End If
Exit_cmdSearch_Click:
    Exit Sub

Err_cmdSearch_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearch_Click
    Me.txtID = ""
    Me.Refresh

09.then Run this application.Result will look like this



Download sample file from below link;

Download

Monday, January 15, 2018

Thursday, November 28, 2013

MS Access Report Parameter



 Here I explain how to set a  Access report to a given parameter,through a combo box
Example
This is the sample data base table I used to explain this scenario.

Then Create a Query using the Fields that you wish to show in your report. It looks like that;
Then you have to create a report based on this query, Use Report wizard to do this easily.
This report shows all the records include in your query.
Lets assume that you want to take customer as your criteria.Based on that:
Next step is creating a unbound form .Then add a combo box that will show the Cus_id field as well as Customer_Name .Use Combo wizard to do this.Set Combo box column property to 2.Hide the Cus_id field by setting the Combo box’s column Width property to 0’:1’
Make sure the combo box bound column is the Cus_id Field.Name the Combo box as cboFindName 
 
Then add the command button to the form. Then under property window click the event procedure belongs to the button and choose code builder option.


 Then under Button Click Event type following code:
 
Me.Visible=False
Name this Form “ParamForm”
Go back to the query.As criteria,on the query’s Cus_id field criteria line write:
Forms!ParamForm!cboFindName
Code the Report’s  open Event :
DoCmd.OpenForm “ParamForm”, , , , , acDialog
Code the Report’s  Close Event :
DoCmd.Close acForm, “ParamForm”


Run the report
The Report will open the form
Find the Customer Name in the Combo Box.Click the Command Button ,When Report  is opened click the refresh button to refresh the report data.