Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2007, 06:58 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Print Access report from SQL stored procedure

A bit of advice would be good, I'm a bit of a newbie but I'm getting better.

When I first set about this project I was advised to use a Union Query as the Record Source for my Report. On my test system I ran the SQL server local to the client front end. Everything seemed fine, however now I have migrated the Database on to the Live Server, I can no longer print reports.

I'm sure I need to use Adodb but I'm unsure of the Syntax.

Here's my code.

Private Sub cmdPrint_Click()

' Prints FactSheet to be given to Foster Children

Dim db As DAO.Database
Dim qd As DAO.QueryDef

Dim stReportName As String
Dim StrCarerID As String

Me.txtFosterID.SetFocus

StrCarerID = Me.txtFosterID.text

Val (StrCarerID)

' Run Stored Procedure

If Len(StrCarerID) Then
    Set db = DBEngine(0)(0)
    Set qd = db.QueryDefs("qryViewFosterFamily")

    qd.sql = "EXEC dbo.sp_ViewFosterFamily" & " " & StrCarerID

    Debug.Print qd.sql

    db.QueryDefs.Refresh

stReportName = "rptFactSheet"

DoCmd.OpenReport stReportName, acViewPreview, , , acWindowNormal

    Set qd = Nothing
    Set db = Nothing

Else
    MsgBox "No Family Details Entered....", vbCritical, "Print Error"
End If

End Sub








Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report, Stored Procedure, Dataset clioz Crystal Reports 0 July 19th, 2006 06:28 PM
Parameterized CRystal report & Stored procedure jay4ever_2000 ASP.NET 1.0 and 1.1 Professional 3 June 6th, 2006 08:53 AM
how to use stored procedure in Access hertendreef ADO.NET 1 June 3rd, 2006 03:04 AM
Setting up stored procedure for Crystal Report.... potato3 SQL Language 1 December 9th, 2004 12:33 PM
Stored procedure as the rowsource for Report (ADP) Tero Access 1 May 12th, 2004 08:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.