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