Application developed with Access 2002, Appendix.


 Print operations , using 2 Logical Query.

  1.  Book Form - Print data corresponding to the search data ....
    The design :


     From the Toolbox add one Command Button: - Print List   ( red arrow)
     

    1. Add the Command Button -cmdPList Properties:
      Use a CommandButton control to begin, interrupt, or end a process. When chosen, a CommandButton appears pushed in and so is sometimes called a push button.
      Name:
      Caption:
      On Click
      cmdPList
      Print List
      (Event Procedure)


    2. The Codes ...
       
      Print data corresponding to the search data

      Private Sub cmdPList_Click()
      ' Variables
      Dim dbs As Database                      ' logical Database declaration
      Dim qdfTemp As QueryDef             ' logical Query declaration
      Dim sqlcross As String

      ' Set the Command Button: - Print List disable
      Me.CmdClose.SetFocus
      If Me.cmdPList.Enabled = True Then Me.cmdPList.Enabled = False

      ' delete Table Tempv
      DoCmd.DeleteObject acTable, "TempV"
      ' create new table TempV and copy TempV_temp to TempV
      DoCmd.CopyObject , "TempV", acTable, "TempV_temp"

      Set dbs = CurrentDb()   ' logical Database Uses current database KJV2002

      ' Create temporary append Query ( copy corresponding data with search from table BibleTable into table TempV.

      ' Sql View
      sqlcross = "INSERT INTO TempV ( Book, BookTitle, Chapter, Verse, TextData )"
      sqlcross = sqlcross & " SELECT DISTINCTROW BibleTable.Book, BibleTable.BookTitle, BibleTable.Chapter, BibleTable.Verse, BibleTable.TextData"
      sqlcross = sqlcross & " FROM BibleTable"
      sqlcross = sqlcross & " WHERE (((InStr([BibleTable]![TextData],'" & vword & "'))<>False))"
      sqlcross = sqlcross & " ORDER BY BibleTable.Book, BibleTable.Chapter, BibleTable.Verse"

      ' Append Query name "Temp_Append"
      vqueryname = "Temp_Append"
      Set qdfTemp = dbs.CreateQueryDef(vqueryname, sqlcross)

      ' Open Query created
      DoCmd.OpenQuery vqueryname, acViewNormal, acEdit

      ' Delete Query  created
      DoCmd.DeleteObject acQuery, vqueryname

      ' Run report name Print_List, using Window Mode type Dialog
      DoCmd.OpenReport "Print_List", acViewPreview, , , acDialog

      End Sub


      Create New Report -
      Print_List
      From the KJV2002:Database dialog box displays, Choose and Click The Tab - Reports and then click New.
      From the new dialog box - New report displays, Select Report Wizard, choose Table TempV , click Ok, and form the other pages, choose and select the following Fields (Book, BookTitle, Chapter, Verse, Textdata)  and click Finish.   New Report appears

      Design,  Report created after modification
       


      Note:  This Report Proprieties

      Record Source: SELECT TempV.Book, TempV.BookTitle, TempV.Chapter, TempV.Verse, TempV.TextData, TempV.ID
      FROM TempV
      ORDER BY TempV.ID;


  2. Book Form - Uses Excel, Word or Html  to Print  special selected chapter of book.
    The design


    From the Toolbox add three Command Buttons: - Excel, Word and HTML   ( red arrow)

    1. Add the Command Button -cmdExcel Properties:
      Name:
      Caption:
      On Click
      cmdExcel
      Excel
      (Event Procedure)


    2. Add the Command Button -cmdWord Properties:.
      Name:
      Caption:
      On Click
      cmdWord
      Word
      (Event Procedure)


    3. Add the Command Button -cmdHtml Properties:
      Name:
      Caption:
      On Click
      cmdPHtml
      HTML
      (Event Procedure)


    4. The Codes ...
       
      ' Uses Excel to print the data corresponding to the specific chapter of book
      Private Sub cmdexcel_Click()

      'Create Query - procedure
      FcreateQuery

      ' Print - Transfer data to  Excel File
      DoCmd.OutputTo acOutputQuery, vqueryname, acFormatXLS, , True

      ' Delete Query created
      DoCmd.DeleteObject acQuery, vqueryname
      End Sub



      ' Uses Word to print the data corresponding to the specific chapter of book
      Private Sub cmdword_Click()

      'Create Query - procedure
      FcreateQuery

      ' Print - Transfer data to Word  File
      DoCmd.OutputTo acOutputQuery, vqueryname, acFormatRTF, , True

      ' Delete Query created
      DoCmd.DeleteObject acQuery, vqueryname
      End Sub



      ' Uses HTML to print the data corresponding to the specific chapter of book
      Private Sub cmdhtml_Click()

      'Create Query - procedure
      FcreateQuery

      ' Print - Transfer data to HTML File
      DoCmd.OutputTo acOutputQuery, vqueryname, acFormatHTML, , True

      ' Delete Query created
      DoCmd.DeleteObject acQuery, vqueryname
      End Sub


      ' Procedure, Create Query
      Sub FcreateQuery()

      ' Variables
      Dim dbs As Database                    ' Logical Database declaration
      Dim qdfTemp As QueryDef           ' Logical Query declaration

      Dim sqlprintx As String

      Set dbs = CurrentDb()                 ' logical Database Uses current database KJV2002

      ' Create Query
      ' Sql View
      sqlprintx = "SELECT BibleTable.Book, BibleTable.BookTitle, BibleTable.Chapter, BibleTable.Verse, BibleTable.TextData"
      sqlprintx = sqlprintx & " FROM BibleTable"
      sqlprintx = sqlprintx & " WHERE (((BibleTable.Book) = '" & Me.CmbBook.Value & "') And ((BibleTable.Chapter) = '" & Me.CmbChapter.Value & "'))"
      sqlprintx = sqlprintx & " ORDER BY BibleTable.Verse"

      ' Operation, create Query name "Print_List_Search".
      vqueryname = "Print_List_Search"
      Set qdfTemp = dbs.CreateQueryDef(vqueryname, sqlprintx)

      End Sub
       

     


Application ... , Part 3
 

Home